Computing.Net > Forums > Unix > Need a unix script to ping servers

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Need a unix script to ping servers

Reply to Message Icon

Name: Kasser Ayubi
Date: May 28, 2003 at 02:28:47 Pacific
OS: sun solaris, win 2000
CPU/Ram: loads
Comment:

HI there, if anyone can help me it will be much appreciated.
I need to make a bourne shell script which will ping a total of 30 servers to make sure they are alive and then print the records onto a file or screen. i was thinking of putting the names of the servers in a text file and then do a for while loop but im young at unix scripting and need some help or a script would be perfect, the flashier the better. please mail me on kasser.ayubi@steria.co.uk



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: May 28, 2003 at 04:38:19 Pacific
Reply:

Homework ?

PING=`which ping`
for hostname in `cat hostlist` ; do
$PING $hostname
if [ $? -eq 0 ] ; then
echo "$hostname reachable"
else
echo "$hostname unreachable"
fi
done

Take this idea and make it platform independent. You want to assign to PING, a command that will try a fixed number of times then return an result code.
For example on HP-UX
ping hostname -n 1 >/dev/null 2>&1


0

Response Number 2
Name: Kasser Ayubi
Date: May 28, 2003 at 04:54:40 Pacific
Reply:

thanks for that reply, very helpfull, anyother replies are appreciated


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Need a unix script to ping servers

I need a shell-script to search www.computing.net/answers/unix/i-need-a-shellscript-to-search/5941.html

Writing a Unix script to ftp files www.computing.net/answers/unix/writing-a-unix-script-to-ftp-files/3934.html

unix script to submit html form www.computing.net/answers/unix/unix-script-to-submit-html-form/1324.html