Operating System - HP-UX
1753809 Members
8455 Online
108805 Solutions
New Discussion юеВ

Re: Script required to check the PING Broken status

 
mjoshi
Trusted Contributor

Script required to check the PING Broken status

Dear,

I would require a script to check PING BROKEN status from a Source file .


With regards,
Mjoshi
5 REPLIES 5
Steven Schweda
Honored Contributor

Re: Script required to check the PING Broken status

I would require a clearer explanation of what
you're trying to check.

A Forum search for keywords like, say:
ping script
might find several things.
mjoshi
Trusted Contributor

Re: Script required to check the PING Broken status

i basically require a script which will check ping response from a source file.source file would have my hostnames. for any hostname which is not reachable will tjrow an error; ping broken on specified hostname.
Dennis Handly
Acclaimed Contributor

Re: Script required to check the PING Broken status

>source file would have my hostnames.

Possibly something like:
for host in $(< file-of-hosts); do
/etc/ping $host -m 1 -n 1
if [ $? -ne 0 ]; then
echo "ping broken on $host" 1>&2
fi
done
mjoshi
Trusted Contributor

Re: Script required to check the PING Broken status

I have cutomized this way:

#!/bin/sh
for host in $(< tmp/hostfile.txt); do
/etc/ping $host -m 1 -n 1
if [ $? -ne 0 ]; then
echo "ping broken on $host" 1>&2
fi
done


root@ggnems21 # sh ping.sh
ping.sh: syntax error at line 2: `$' unexpected

Is failing..


With regards,
Mjoshi
Dennis Handly
Acclaimed Contributor

Re: Script required to check the PING Broken status

>root@ggnems21 # sh ping.sh
>ping.sh: syntax error at line 2: `$' unexpected

 

You need to use a real shell: ksh or Posix shell

Otherwise you have to fall back to the archaic: `cat tmp/hostfile.txt`