Hi Folks,
Scenario:
I used the following shell script to see ping status, and got a report out of that based on the standard output value, and it worked:
for i in `cat /tmp/momin/servers`
do
echo PINGING $i....
ping $i 1
if [ $? -eq 0 ]
then
echo ping test passed!!!
echo $i >> /tmp/momin/passed
echo -------------------------------------------
else
echo ping Failed!
echo $i >> /tmp/momin/failed
echo --------------------------------------------
echo
fi
done
In the output I noticed three types of output messages:
- ping: unknown host tordb2
- no answer mondb1
- vandb7 is alive
The hostnames with error messages 1 and 2 went to the 'failed' report file, and the hostnames with error message 3 were directed to the 'passed' file.
Help Needed Here:
What logic can I use in my shell script / scripted command, to generate 3 files based on the 3 messages? :wall:
Thanks in advance,
Momin