[Ilugc] Shell scripting help

  • From: cyborg4k@xxxxxxxxx (Shakthi Kannan)
  • Date: Sun Jan 9 13:12:06 2005

Hi Rohit,

--- Rohit Baisakhiya <rohitbaisakhiya@xxxxxxxxx>
wrote:

I need to make
a script which can
ping an ip and can write to a file in values of 0 or
1(0 if it
receives ping reply and 1 if it receives no reply).

Try this:

#!/bin/bash
ping -c 1 www.yahoo.com 1>/dev/null
return=`echo $?`
if [ $return -eq 0 ]; then     #Success
  echo "0" >> /tmp/log.file
else                           #Failure   
  echo "1" >> /tmp/log.file
fi

Cheers,

K Shakthi

=====
--------------------------------------------------------------------------
K Shakthi
Specsoft (Hexaware Technologies), ASIC Design Center
http://www.geocities.com/shakthimaan
--------------------------------------------------------------------------


        
                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - You care about security. So do we. 
http://promotions.yahoo.com/new_mail

Other related posts: