<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Ping return code in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015658#M576705</link>
    <description>ping does return a success or failure code. BUT the return code has nothng to do with the packets! The return code will be non-zero if the hostname cannot be resolved (ie, DNS error or non-existant hostname). When you think about ping's capability, there are a lot of possibilities including some of the packets make it through and some don't...how would you pick a return code for 'flakey' returns?&lt;BR /&gt;&lt;BR /&gt;So you must always grep for the packet loss and for best performance, send several pings and grep for anything that is not 0% loss. It's also a good idea to look at the last line for unusual min/avg/max values (which might indicate a bad network).</description>
    <pubDate>Fri, 04 Jul 2003 14:31:19 GMT</pubDate>
    <dc:creator>Bill Hassell</dc:creator>
    <dc:date>2003-07-04T14:31:19Z</dc:date>
    <item>
      <title>Ping return code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015652#M576699</link>
      <description>I made a shell script that ping computers to check if there are alive.&lt;BR /&gt;But the ping command does not return an error if no packets are received.&lt;BR /&gt;Any idea to get a return code ?&lt;BR /&gt;Thanks</description>
      <pubDate>Fri, 04 Jul 2003 10:52:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015652#M576699</guid>
      <dc:creator>Philippe NAVAJAS</dc:creator>
      <dc:date>2003-07-04T10:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Ping return code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015653#M576700</link>
      <description>perform a "ping [hostname] -n 5" and capture the output to a file.&lt;BR /&gt;&lt;BR /&gt;Then grep the file for the keywords "packets transmitted" and "packets received", load up the numbers returned. If packets received is 0, ping was not succesfull!&lt;BR /&gt;&lt;BR /&gt;Share and Enjoy! Ian</description>
      <pubDate>Fri, 04 Jul 2003 10:54:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015653#M576700</guid>
      <dc:creator>Ian Dennison_1</dc:creator>
      <dc:date>2003-07-04T10:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Ping return code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015654#M576701</link>
      <description>ping $host -n 1 | grep -q '1 packets received' &lt;BR /&gt;if [ $? = 0 ] &lt;BR /&gt;  then &lt;BR /&gt;    echo "$host: OK" &lt;BR /&gt;  else &lt;BR /&gt;    echo "$host: FAIL" &lt;BR /&gt;fi &lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jul 2003 11:00:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015654#M576701</guid>
      <dc:creator>twang</dc:creator>
      <dc:date>2003-07-04T11:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Ping return code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015655#M576702</link>
      <description>ping 1&lt;BR /&gt;STAT1=$?&lt;BR /&gt;ping 2&lt;BR /&gt;STAT2=$?&lt;BR /&gt;if [[ $STAT1 != 0 ]]&lt;BR /&gt;then&lt;BR /&gt;echo alert1 | mailx -s "ALERT1 SUBJECT" you@yourdomain.com&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [[ $STAT2 != 0 ]]&lt;BR /&gt;then&lt;BR /&gt;echo alert2 | mailx -s "ALERT1 SUBJECT" you@yourdomain.com&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Note:&lt;BR /&gt;&lt;BR /&gt;'$?' saves success code of the last command completed, assign it to a variable like 'STAT1', run another command, save that success code in 'STAT2', etc.</description>
      <pubDate>Fri, 04 Jul 2003 11:27:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015655#M576702</guid>
      <dc:creator>AlienRoadShow</dc:creator>
      <dc:date>2003-07-04T11:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Ping return code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015656#M576703</link>
      <description>ping does return a command code as does almost every properly written utility.&lt;BR /&gt;&lt;BR /&gt;In a shell script getting a return code is easy.&lt;BR /&gt;&lt;BR /&gt;ping server.schmobagel.com # &lt;WAIT 30="" seconds="" for="" an="" answer=""&gt;&lt;BR /&gt;&lt;BR /&gt;return_code=$?&lt;BR /&gt;&lt;BR /&gt;if [ $return_code ne 0 ] then&lt;BR /&gt;   echo "ping server.schmobagel.com is down"&lt;BR /&gt;   # email the administrator&lt;BR /&gt;   # start a program to take over services&lt;BR /&gt;   # blah blah blah&lt;BR /&gt;else&lt;BR /&gt;    echo "all is well"&lt;BR /&gt;    return 0&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Somewhere in my past posts there is a fully working copy of this script outline.&lt;BR /&gt;&lt;BR /&gt;SEP&lt;BR /&gt;&lt;BR /&gt;&lt;/WAIT&gt;</description>
      <pubDate>Fri, 04 Jul 2003 11:31:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015656#M576703</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-07-04T11:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Ping return code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015657#M576704</link>
      <description>Philippe,&lt;BR /&gt;&lt;BR /&gt;I observed the same problem as you. I had a function working on HP-UX 11.0 using the return code, but one day it stopped working (OS version, ping patch, ???).&lt;BR /&gt;&lt;BR /&gt;Now I use the following function that seems OK at least on HP-UX11i v1:&lt;BR /&gt;&lt;BR /&gt;test_server_access() {&lt;BR /&gt;#&lt;BR /&gt;# Test if the server given as parameter answers to ping&lt;BR /&gt;#&lt;BR /&gt;# Usage:&lt;BR /&gt;#       test_server_access  &lt;SERVER_NAME&gt;&lt;BR /&gt;#&lt;BR /&gt;# Return status:&lt;BR /&gt;#       0 = OK&lt;BR /&gt;#       1 = KO&lt;BR /&gt;#&lt;BR /&gt;    # Test access to the server&lt;BR /&gt;    RETURN=`ping $1 30 3 | tail -1 | awk '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;    if [ ! $RETURN = "round-trip" ]; then&lt;BR /&gt;      error_print "host $1 does not answer to ping" ; return 1&lt;BR /&gt;    else&lt;BR /&gt;      return 0&lt;BR /&gt;    fi&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Luc      ;-)&lt;/SERVER_NAME&gt;</description>
      <pubDate>Fri, 04 Jul 2003 12:56:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015657#M576704</guid>
      <dc:creator>Luc Caissial</dc:creator>
      <dc:date>2003-07-04T12:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Ping return code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015658#M576705</link>
      <description>ping does return a success or failure code. BUT the return code has nothng to do with the packets! The return code will be non-zero if the hostname cannot be resolved (ie, DNS error or non-existant hostname). When you think about ping's capability, there are a lot of possibilities including some of the packets make it through and some don't...how would you pick a return code for 'flakey' returns?&lt;BR /&gt;&lt;BR /&gt;So you must always grep for the packet loss and for best performance, send several pings and grep for anything that is not 0% loss. It's also a good idea to look at the last line for unusual min/avg/max values (which might indicate a bad network).</description>
      <pubDate>Fri, 04 Jul 2003 14:31:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015658#M576705</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2003-07-04T14:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Ping return code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015659#M576706</link>
      <description>For what it seems your are trying to use ping to do if you can load additional software onto the machine I would suggest you load fping onto it.  From the manpage of fping:&lt;BR /&gt;&lt;BR /&gt;fping is a ping-like program which uses the Internet Control Message&lt;BR /&gt;Protocol (ICMP) echo request to determine if a host is up. fping&lt;BR /&gt;is different from ping in that you can specify any number of&lt;BR /&gt;hosts on the command line, or specify a file containing the&lt;BR /&gt;lists of hosts to ping. Instead of trying one host until it&lt;BR /&gt;timeouts or replies, fping will send out a ping packet and move&lt;BR /&gt;on to the next host in a round-robin fashion. If a host replies,&lt;BR /&gt;it is noted and removed from the list of hosts to check. If a&lt;BR /&gt;host does not respond within a certain time limit and/or retry&lt;BR /&gt;limit it will be considered unreachable.&lt;BR /&gt;&lt;BR /&gt;You can obtain a copy from &lt;A href="http://www.securityfocus.com/data/tools/fping-2.2b1.tar.gz" target="_blank"&gt;http://www.securityfocus.com/data/tools/fping-2.2b1.tar.gz&lt;/A&gt;</description>
      <pubDate>Fri, 04 Jul 2003 14:41:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015659#M576706</guid>
      <dc:creator>William Wong_2</dc:creator>
      <dc:date>2003-07-04T14:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Ping return code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015660#M576707</link>
      <description>Hello!&lt;BR /&gt;&lt;BR /&gt;There is no return code from ping command,&lt;BR /&gt;you ccan write script that do this&lt;BR /&gt;&lt;BR /&gt;ping &lt;HOSTNAME&gt; -n 1 | grep -q "1 packets received" &lt;BR /&gt;&lt;BR /&gt;if ( $status == 0 ) then&lt;BR /&gt;   print "connection"&lt;BR /&gt;else &lt;BR /&gt;   print "no connection"&lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;You can write your program on C that will&lt;BR /&gt;open socket to the wanted hosts and&lt;BR /&gt;if succed/or not then return any code that you&lt;BR /&gt;want.&lt;BR /&gt;&lt;BR /&gt;Caesar&lt;/HOSTNAME&gt;</description>
      <pubDate>Sat, 05 Jul 2003 17:01:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015660#M576707</guid>
      <dc:creator>Caesar_3</dc:creator>
      <dc:date>2003-07-05T17:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Ping return code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015661#M576708</link>
      <description>Here is a Perl script, ping.pl that will return a valid exit status. Invoke as ping.pl -u for full usage.&lt;BR /&gt;</description>
      <pubDate>Sat, 05 Jul 2003 20:09:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ping-return-code/m-p/3015661#M576708</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-07-05T20:09:05Z</dc:date>
    </item>
  </channel>
</rss>

