Hi,
Hav automated a process, and it is working fine.
for first process alone
status = ` ps -ef |grep a `
if [ $status -eq 1]
then
echo " Success" > temp/logfile
else
echo " Failure" > temp/logfile
fi
Now I hav to write script to automated some 2 process and then send mail using cron..
status = ` ps -ef |grep a `
if [ $status -eq 1]
then
echo " Success" > temp/logfile
else
echo " Failure" > temp/logfile
fi
status1 = ` ps -ef |grep b `
if [ $status1 -eq 1]
then
echo " Success" > temp/logfile
else
echo " Failure" > temp/logfile
fi
This script works when it is for one process, but when I run for two process, it is not workin, I recieve the result of the first process alone.
Pls, can u help me on this..
Thanks in Advance
aigles
April 27, 2010, 3:29am
2
Modify the redirection for the second test
status=` ps -ef |grep a `
if [ $status -eq 1 ]
then
echo " Success" > temp/logfile
else
echo " Failure" > temp/logfile
fi
status1=` ps -ef |grep b `
if [ $status1 -eq 1 ]
then
echo " Success" >> temp/logfile
else
echo " Failure" >> temp/logfile
fi
You can also write :
{ ps -ef |grep a && echo Failure || echo Success ;} > temp/logfile
{ ps -ef |grep b && echo Failure || echo Success ;} >> temp/logfile
Jean-Pierre.
Hi Aigles,
Still M getting the result of first process alone..
Plz can u help me..
Thanks
aigles
April 27, 2010, 4:23am
4
Add 'set +x' at the begining of the script and show us the output.
set -x
status=` ps -ef |grep a `
if [ $status -eq 1 ]
then
echo " Success" > temp/logfile
else
echo " Failure" > temp/logfile
fi
status1=` ps -ef |grep b `
if [ $status1 -eq 1 ]
then
echo " Success" >> temp/logfile
else
echo " Failure" >> temp/logfile
fi
Jean-Pierre
Scott
April 27, 2010, 5:45am
5
Hi.
What exactly are you hoping to achieve here? status and status1 will contain a string of process information, not a number.
If you want the count of processes then you should look at piping the output of ps | grep through wc (or using grep -c). The aigles alternative is nicer in any case
Hi,
Now the script is running fine..
Thank u so much..