I am pretty new to Unix shell scripting, but wondered if anyone could help (in layman's terms if possible!!)
I have a shell script which ultimately sends an alert to an email address if part of a batch of programs fails. Here's the script that sends the email:
Script: 6check.csh
#!/bin/csh
set alertperson = `cat /export/home/bdodym/alert.person`
if (-f critabend.tag ) then
cat callout6.msg | rmail $alertperson
rm critabend.tag
endif
However, if I run through cron, it still seems to be executing the scripts (e.g files are created that I'm asking the script to do generally), but the email is not being sent as I would hope. In the below crontab, 6start.sh has a number of scripts to run through, the last of which is 6check2.csh (as per above)
Does anyone know if there is anything additional I need to do add to either the script, or cron, to ensure the email sends? I think (from my VERY limited knowledge of this kind of thing!) that its something to do with the fact cron is running in the background rather than the terminal, as per the command line success. But, this is the final piece of the jigsaw and I just need to ensure I can get it to fit!!
and check what's wrong. Additionally you can add a "set -x" into your shell script to see what's going on inside.
Don't forget that cronjobs usually don't have the same environment like when a user would start the script - so you should source the .profile or .kshrc or .bashrc, whatever your environment setup files are.
zaxxon - thankyou for your reply. I was just reading up about "source". So if I were to source it, would I just add the source to 6check.sh (the emailing bit) or 6start.sh too (which, as mentioned just contains a list of scripts to run, as per below...)
use vi editor to create a file using .sh extension which will have shell scripts to execute.
then execute this file using command
sh filename.sh
e.g. if u have created a shell file sample.sh then u will execute this file using
sh sample.sh
this command...
go and try different kinds of shell scripts you will definitely explore more about UNIX.