Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

Generic programming in an Interpreted language (as opposed to compiled) executed by a running Shell. Sometimes referred to as "Glue Code" due to the practice of managing the execution and output of one or more compiled binaries and passing said output to another series of commands.

621 questions
0
votes
2 answers

Update crontab of my web user using "sudo"

I need to update the crontab of my web user (the user that is executing all websites). In my crontab I'm using shell script with commands that needs to use "sudo". The script is well executed but I get error messages, a few examples below : mv:…
tonymx227
  • 101
0
votes
1 answer

Copying Content from a file to another when a new line is added using poweshell script

I have a file named server1.txt and one more file named server1_copy.txt. In server1.txt, all logs will be added from the application. So whenever a new line is added in the server1.txt, we need to copy that and paste it in the server1_copy.txt. We…
saffron
  • 143
  • 1
  • 3
  • 12
0
votes
1 answer

how to run a bash backup script with simultaneous processes without getting stuck with infinite looping?

I wrote this script for run postgresql pg_dump of multiples schemas. Since it takes much time to finishes all i'd improved it by running simultaneous dumps with this: for SCHEMA in $SCH do while [ $(jobs | wc -l | xargs) -ge $PROC ]; do sleep 5;…
0
votes
2 answers

A shell script to ssh, watch log file, and run command

I want a shell script that connects to a server via ssh, starts watching a log, and then touches a file. It's important that I do them in that order, because I want to see in the log the effects of the second command. How do I write this? If I try…
Rob N
  • 101
  • 4
0
votes
0 answers

Powershell script to delete oldest files

I DO NOT want to "delete files older than X days." If I wanted to do this, I'd just pick one of the thousands of scripts out there that have already been written for that purpose, and I wouldn't bother asking such a trivial question on…
0
votes
1 answer

su - with automatic change directory once su command is done in shell scripting

im not familiar in shell scripting but im trying to achieve at least this script but my problem is once superuser rt is done logging in it brings me to this [rt@superuser root]$ instead of reading the second line, i would like to achieve at least…
0
votes
1 answer

Trim and allign an output of command in expect script

{ echo ' ' ;echo ' IP : ' ;ip route get 8.8.8.8 | cut -d' ' -f7,8 | tr -d 'src' ;echo ' ' ;dmidecode -t bios | grep -iw 'Version' ;echo ' ' ;} the output of above command mentioned is: IP : 10.0.0.1 Version: 1.8 but i want to allign it…
GauravG
  • 19
  • 7
0
votes
2 answers

saving sql dump error in a file

I want to save error if error comes, into a file. But error not redirecting into file. I get below error and its not redirecting into file. mysqldump: Couldn't execute 'SHOW FIELDS FROM `v_comloc`': View 'nextgendev_new.v_comloc' references invalid…
addi jeo
  • 3
  • 2
0
votes
1 answer

Case statement not working properly in shell script

The case statement in the bash script does not work. Below is the snippet of my shell script. usage="Usage: \n servicer [ service argument ] {-h}\n" invalid="\n not a valid option\n" argument="\n Please use -h option for help\n" while getopts…
0
votes
1 answer

Parsing Command Response in Bash Script

I need a bash script that takes the output of a shell command and parses that output to pull out the state. If the State is: Bad, an email should be sent. ~$ bucardo status PID of Bucardo MCP: 2074 Name State Last good Time …
ruscom
  • 1
  • 1
0
votes
1 answer

Systemd: Unit-file timeout after start

I have written a bashscript with the following content: #!/bin/bash cd /opt/ut_server/System ./ucc-bin-linux-amd64 server DM-Rankin?game=XGame.xDeathMatch?mutator=AntiTCC2009r6.MutAntiTCCFinal,utcompv17a.MutUTComp?AdminName=admin?AdminPassword=1111…
mncache
  • 3
  • 1
  • 4
0
votes
2 answers

Can't get cron to output a GUI message / how to make user aware cron is being executed

I need to run, on Ubuntu 18.04, via cron a script, myscript.sh that I want, among other things, to display to the user a message when it is being run so that he is aware that cron is being run (perhaps there are also ways to do this that somehow…
0
votes
1 answer

Shell Script to kill long running PIDs

I was hoping someone could answer a question regarding this shell script that I've just gotten while taking over a website previously owned by someone else. This was their backup fix to catch any long running apache workers which their app did not…
Analog
  • 202
  • 2
  • 12
0
votes
0 answers

Trying to get SSH output from within a for loop in a script

I'm trying to SSH into a bunch of hosts in order, and run a command to get a list of users on each one. Outside of a for loop, the output shows up just fine one-by-one. Inside a for loop, it disappears. How do I make that output…
Mark S
  • 1
0
votes
1 answer

Wich Shebang should you use in a shell sript?

Sorry, this is maybe a stupid question, but I am new to shell scripts. I have a file called oem-device-name.sh. I need to execute an external check for Zabbix: https://www.zabbix.com/documentation/5.0/manual/config/items/itemtypes/external The…
Jarne
  • 25
  • 1
  • 9