The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #12 (permalink)  
Old 10-24-2008
Lasthitlarry Lasthitlarry is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 6
Quote:
Originally Posted by avis1981 View Post
Can you try this one:

#! /bin/ksh
IPLIST=`cat ./pinglist1.txt`
for ip in $IPLIST
do
echo $ip
ping -c 2 $ip >>log.txt
if [[ $? -eq 0 ]]
then
print $ip "PINGS">>pingresults.txt
else
print $ip "DOESN'T PING">>pingresults.txt
fi
done
THANKS.

I just had to modify it a bit, changed [[ ]] to [ ] and print to echo and it worked.

pingresults.txt produced the following (xxx for security purposes):

xxx.xxx.193.16 DOESN'T PING
xxx.xxx.135.194 PINGS

Thanks!