Loading ...
Sorry, an error occurred while loading the content.

13484Re: Ping return value

Expand Messages
  • bullfrog528
    Jun 11, 2006
    • 0 Attachment
      Remove the ampersand from the ping line

      ping -c 1 192.168.0.20 > /dev/null

      and your script will run as expected - currently telling it to run in
      background and not wait for completion.

      Bullfrog

      --- In nslu2-linux@yahoogroups.com, schlippp@... wrote:
      >
      > Hi everyone,
      >
      > I'm having a problem with ping included in the lastest version of
      > Unslung ( v 6.8). I explain, I'm trying to use this small scrit to
      > determine wether or nor a given host is up or down.
      >
      > #!/bin/sh
      > ping -c 1 192.168.0.20 &> /dev/null
      > if [ $? = 0 ]
      > then
      > echo "up"
      > else
      > echo down
      > fi
      >
      > The problem is that I always get the same result "up" even when the
      > host is down. I suspect that ping return 0 before trying to contact
      the
      > host. I think to that because of the output of my script that
      display
      > "up" before displaying the various infos of ping.
      >
      > Does anyone have an idea on how I can fix my script.
      >
      > Regards Jerome
      > ___________________________________________________
      > Try the New Netscape Mail Today!
      > Virtually Spam-Free | More Storage | Import Your Contact List
      > http://mail.netscape.com
      >
    • Show all 3 messages in this topic