shell scripts
Hi,
I would appreciate help with the following. I am writing a shell script that call several different perl files. To be exact let us say that I am calling four perl files. We will call them a.pl, b.pl, c.pl, and d.pl. I want to run them in the following order: a.pl, b.pl, c.pl, d.pl. If both a.pl and b.pl do not run properly I don't want to run c.pl, or d.pl. If both a.pl and b.pl run okay but c.pl does not run properly I don't want to run d.pl. Each time ther is an error I want to report it in a log file. I would like to know the best way of doing this in a shell script. Also, is there something better I can do instead of just writing an error to the log file. One of the perl files that I am calling is loading a database. If the loading doesn't work properly I would like to roll back instead of having an improper loading. thank in advance! |
I have a couple of links that i found useful in writing my shell scripts for bash:
Beginner's guide: http://www.tldp.org/LDP/Bash-Beginne...tml/index.html Advanced guide (more indepth than the one above): http://www.tldp.org/LDP/abs/html/index.html And another: http://quong.best.vwh.net/shellin20/ And something i found very quick and easy for variables in bash: http://www.linuxvoodoo.com/resources...eclareref.html Shell scripts basically run commands from the console except you can put them into a script and manipulate multiple commands, set variables, make loops (for repeated commands that would otherwise be tedious), read and write to files easily, etc. For example the command Code:
$ echo "My name is Alex" >> ~/tmp/name.txt Code:
#!/bin/bash Code:
#!/bin/bash $ sh thescript.sh filename.txt or $ ./thescript.sh filename.txt |
Try this:
Code:
#!/bin/bash Here's an email submit fn you could use: Code:
function mail_msg() Code:
mail_msg "$0: Unable to <your msg here> " "$0: Failed !" |
Maybe I'm just being a little too simplistic on this...
Couldn't you just do this: a.pl && b.pl && c.pl && d.pl || mail -s "the script failed" yourname@your.com < /dev/null Check this out: http://www.freeos.com/guides/lsst/ch04sec3.html |
All times are GMT -5. The time now is 04:27 PM. |