Hi All,
please help me out with this problem.
While running my mail_out_original.ksh in CRT window, it disconnects from the server saying not connected
Here is my code : (please see the attachment)
____________________________________________________________
#!/bin/ksh
## Load .profile to make sure crontab run jobs are loading all env variables
. $HOME/.profile
## Change into the directory
cd /u/gcsm_admin/mail_out
## Create the touch file
touchfile="/u/gcsm_admin/mail_out/running"
## If there is no other mail_out running the remove the touchfile
NOTRUN=$(ps -ef | grep "mail_out.ksh" | wc -l)
if [ $NOTRUN -le 2 ]
then
rm $touchfile 2>/dev/null
fi
## Exit routine
fnExit()
{
if [ -r $touchfile ]
then
rm $touchfile 2>/dev/null
fi
exit -1
}
## Set a trap to remove the touch file
trap fnExit ERR
## If we are already running then exit
if [ -r $touchfile ]
then
exit
fi
## Create a touch file
touch $touchfile
## Extra process to restart if something hangs
(
PARENT=$$
sleep 600
RUNNING=$(ps -ef | egrep "$PARENT.*mail_out" | wc -l)
if [ $RUNNING -gt 1 ]
then
echo "The pop email processor has been restarted.
Please verify this process actually worked by checking if email from case updates are being sent.
Thanks,
Support" | mailx -s 'MAIL OUT PROGRAM DOWN!'
nagarajec@gmail.com
rm $touchfile
/usr/local/bin/killpg $$
exit -1
fi
)&
WAITPROC=$!
cnt=0
while [ $cnt -lt 1 ]
do
## Increment our counter
cnt=$(expr $cnt + 1)
## Run the program
/u/gcsm_admin/mail_out/mail_out.pl
sleep 1
done
## Get rid of the touch file
rm $touchfile
## Kill the monitor process and exit
trap "" ERR
/usr/proc/bin/ptree $WAITPROC | awk '{ print "kill -9 " $1 " 2> /dev/null "}' | ksh
exit 0
____________________________________________________________
your help will be appreciated ...