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
3
votes
1 answer

How do I find the biggest files on multiple servers and sum up their size?

I am trying to find the biggest files in the /export/home directory and add up (sum) their sizes. Script: #!/bin/bash filename=hostnames > export_home.log while read -r -a line do hostname=${line//\"} echo $hostname":" >> export_home.log …
ujjain
  • 3,983
  • 16
  • 53
  • 91
3
votes
2 answers

supress expansion of * in echo

I am working on a script which dynamically executes some queries on daily basis. These queries are coming from a table in the database. Here is the sample output of the query table: +---------------+-------------------------------+---------+ |…
3
votes
1 answer

echo $? doesn't work when executed remotely

When I execute a command as below it gives me an output as expected but when I run the same command on remote server it always gives me echo $? as 0. locally # # echo $? Remotely # ssh server " ; echo $? " Now in case…
user154645
  • 33
  • 4
3
votes
2 answers

trap "" HUP v.s Nohup ? How can I run a portion of shell script in nohub mode?

I want to run a shell script over the weekend, but I wanna make sure if the terminal loses the connection, my script won't be terminated. I use nohup for the whole script invokation, but I also want to execute some portion of my shell script in a…
Alex
  • 31
  • 1
  • 3
3
votes
2 answers

How can I kill and wait for background processes to finish in a shell script when I Ctrl+C it?

I'm trying to set up a shell script so that it runs background processes, and when I ctrl+C the shell script, it kills the children, then exits. The best that I've managed to come up with is this. It appears that kill 0 -INT also kills the script…
slipheed
  • 131
  • 1
  • 2
3
votes
5 answers

Command does not execute in crontab while command itself works just fine

I have this script from Colin Johnson on Github - https://github.com/colinbjohnson/aws-missing-tools/tree/master/ec2-automate-backup It seems great. I have modified it to send email to myself every time an EBS snapshot is created or deleted. The…
ericn
  • 553
  • 2
  • 8
  • 20
3
votes
5 answers

How to execute shell scrips without creating files

How is it possible to execute a shell script without creating a file? For example assume I have the following script (testscript): #!/bin/bash function run_free() { free -m } run_free I then of course can execute this with: sh testscript I want…
Justin
  • 5,328
  • 19
  • 64
  • 84
3
votes
3 answers

Email to run a bash script

I have a bash script to restart a service that runs every 3am to guarantee that the service isn't crashed when users require it. However, I need to provide a simpler way for my partner (that isn't from IT area) to run this script when something go…
João Daniel
  • 349
  • 3
  • 6
  • 10
3
votes
1 answer

shell script (KSH) + set file to param & perform test between param and string

in my linux machine red-hat 5.1 - in ppp file - I have only the signature.pl string !!! remark - third application write the signature.pl string in to ppp file I set ppp file in $a param And compare $a with signature.pl But as all see here this…
Eytan
  • 611
  • 6
  • 13
  • 27
3
votes
2 answers

Using Gentoo's `ebegin`, `eend` etc under Ubuntu

We're quite fond of the style of the ebegin, eend, eerror, eindent etc commands used by Portage and other tools on Gentoo. The green-yellow-red bullets and standard layout make for very quick spotting of errors, on what would otherwise be very grey…
Marcus Downing
  • 788
  • 10
  • 18
3
votes
1 answer

including the current directory in a .reg script

I have a .reg script: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SeleniumRC\Parameters] "Application"="C:\\Program Files…
mcintyre321
  • 169
  • 1
  • 6
3
votes
1 answer

How can I output the chkconfig results to a file within a shell script?

When I run the following from the linux command line it works properly and populates the chkconfig.bak file correctly : #chkconfig --list > chkconfig.bak But when the command is run from a daily shell script the chkconfig.bak file comes out…
Haluk
  • 943
  • 2
  • 15
  • 20
3
votes
2 answers

Measuring "loading time in milliseconds" every minute

I have apache running on a virtual server, which in periods gives very bad performance - even when retrieving static JPG or PNG files. This only happens once in a while, so it's hard for me to document it to the hosting company. Is there a good tool…
3
votes
2 answers

What is wrong? "Syntax error: unexpected end of file"

I keep getting this error, do you guys know what is wrong? rapache is an alias for restart apache mugbear:/usr/bin# cat /usr/bin/mkdomain if [ -d "/srv/www/$1" ]; then echo "Domain $1 already…
Strawberry
  • 1,132
  • 4
  • 15
  • 27
3
votes
3 answers

Using if else statement inside shell module in ansible playbook

I am trying to run if else statement inside shell module in ansible playbook but looks like my else statement is not executing in any case. - name: verify application/database processes are not running shell: if ps -eaf | egrep…