Is there a ping-like program that will return false when a packet is lost?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
-1
down vote

favorite












I'm trying to diagnose network instability on my home LAN -- I'm losing connectivity between my router and my cable modem. In my shell script, I'd like to ping the first ip address past the modem, and return false when that fails, so that I can trigger other actions in my script.



Does anyone know of such a beast?







share|improve this question

























    up vote
    -1
    down vote

    favorite












    I'm trying to diagnose network instability on my home LAN -- I'm losing connectivity between my router and my cable modem. In my shell script, I'd like to ping the first ip address past the modem, and return false when that fails, so that I can trigger other actions in my script.



    Does anyone know of such a beast?







    share|improve this question





















      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      I'm trying to diagnose network instability on my home LAN -- I'm losing connectivity between my router and my cable modem. In my shell script, I'd like to ping the first ip address past the modem, and return false when that fails, so that I can trigger other actions in my script.



      Does anyone know of such a beast?







      share|improve this question











      I'm trying to diagnose network instability on my home LAN -- I'm losing connectivity between my router and my cable modem. In my shell script, I'd like to ping the first ip address past the modem, and return false when that fails, so that I can trigger other actions in my script.



      Does anyone know of such a beast?









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jul 18 at 14:30









      Barton Chittenden

      23217




      23217




















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          5
          down vote













          Yes, it is called ping.



          Try something like this (in bash):



          while true ; do 
          if ping -c 1 10.202.15.54 > /dev/null ; then
          echo "It works"
          else
          echo "It does not work"
          fi
          sleep 5
          done





          share|improve this answer






























            up vote
            0
            down vote













            ping -c 1 $my_host > /dev/null ; if [ $? -eq 0 ]; then "echo all good";else "echo error"





            share|improve this answer




























              up vote
              0
              down vote













              I'd do this, you'd get a log so you could run it over time and graph the result in excel.



              #!/bin/bash
              #Script to ping the IP after the gateway.

              LOG="ping.csv"
              TARGET="10.0.0.1"

              while :
              do
              if `ping -c1 $TARGET > /dev/null `
              then
              STATUS="OK"
              else
              STATUS="FAIL"
              fi

              echo "`date +'%D %H:%M:%S'` : $STATUS "
              echo "`date +'%D %H:%M:%S'` , $STATUS " >> $LOG
              sleep 30
              done





              share|improve this answer




























                up vote
                -1
                down vote













                Pretty simple:



                $ ping -c 1 -W 3 www.go.org | grep -q "100% packet loss" && echo "Packet loss" || echo "Packet received"





                share|improve this answer





















                  Your Answer







                  StackExchange.ready(function()
                  var channelOptions =
                  tags: "".split(" "),
                  id: "106"
                  ;
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function()
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled)
                  StackExchange.using("snippets", function()
                  createEditor();
                  );

                  else
                  createEditor();

                  );

                  function createEditor()
                  StackExchange.prepareEditor(
                  heartbeatType: 'answer',
                  convertImagesToLinks: false,
                  noModals: false,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: null,
                  bindNavPrevention: true,
                  postfix: "",
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  );



                  );








                   

                  draft saved


                  draft discarded


















                  StackExchange.ready(
                  function ()
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457014%2fis-there-a-ping-like-program-that-will-return-false-when-a-packet-is-lost%23new-answer', 'question_page');

                  );

                  Post as a guest






























                  4 Answers
                  4






                  active

                  oldest

                  votes








                  4 Answers
                  4






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes








                  up vote
                  5
                  down vote













                  Yes, it is called ping.



                  Try something like this (in bash):



                  while true ; do 
                  if ping -c 1 10.202.15.54 > /dev/null ; then
                  echo "It works"
                  else
                  echo "It does not work"
                  fi
                  sleep 5
                  done





                  share|improve this answer



























                    up vote
                    5
                    down vote













                    Yes, it is called ping.



                    Try something like this (in bash):



                    while true ; do 
                    if ping -c 1 10.202.15.54 > /dev/null ; then
                    echo "It works"
                    else
                    echo "It does not work"
                    fi
                    sleep 5
                    done





                    share|improve this answer

























                      up vote
                      5
                      down vote










                      up vote
                      5
                      down vote









                      Yes, it is called ping.



                      Try something like this (in bash):



                      while true ; do 
                      if ping -c 1 10.202.15.54 > /dev/null ; then
                      echo "It works"
                      else
                      echo "It does not work"
                      fi
                      sleep 5
                      done





                      share|improve this answer















                      Yes, it is called ping.



                      Try something like this (in bash):



                      while true ; do 
                      if ping -c 1 10.202.15.54 > /dev/null ; then
                      echo "It works"
                      else
                      echo "It does not work"
                      fi
                      sleep 5
                      done






                      share|improve this answer















                      share|improve this answer



                      share|improve this answer








                      edited Jul 18 at 15:00


























                      answered Jul 18 at 14:37









                      andcoz

                      11.5k32938




                      11.5k32938






















                          up vote
                          0
                          down vote













                          ping -c 1 $my_host > /dev/null ; if [ $? -eq 0 ]; then "echo all good";else "echo error"





                          share|improve this answer

























                            up vote
                            0
                            down vote













                            ping -c 1 $my_host > /dev/null ; if [ $? -eq 0 ]; then "echo all good";else "echo error"





                            share|improve this answer























                              up vote
                              0
                              down vote










                              up vote
                              0
                              down vote









                              ping -c 1 $my_host > /dev/null ; if [ $? -eq 0 ]; then "echo all good";else "echo error"





                              share|improve this answer













                              ping -c 1 $my_host > /dev/null ; if [ $? -eq 0 ]; then "echo all good";else "echo error"






                              share|improve this answer













                              share|improve this answer



                              share|improve this answer











                              answered Jul 18 at 14:43









                              alpha

                              1,241317




                              1,241317




















                                  up vote
                                  0
                                  down vote













                                  I'd do this, you'd get a log so you could run it over time and graph the result in excel.



                                  #!/bin/bash
                                  #Script to ping the IP after the gateway.

                                  LOG="ping.csv"
                                  TARGET="10.0.0.1"

                                  while :
                                  do
                                  if `ping -c1 $TARGET > /dev/null `
                                  then
                                  STATUS="OK"
                                  else
                                  STATUS="FAIL"
                                  fi

                                  echo "`date +'%D %H:%M:%S'` : $STATUS "
                                  echo "`date +'%D %H:%M:%S'` , $STATUS " >> $LOG
                                  sleep 30
                                  done





                                  share|improve this answer

























                                    up vote
                                    0
                                    down vote













                                    I'd do this, you'd get a log so you could run it over time and graph the result in excel.



                                    #!/bin/bash
                                    #Script to ping the IP after the gateway.

                                    LOG="ping.csv"
                                    TARGET="10.0.0.1"

                                    while :
                                    do
                                    if `ping -c1 $TARGET > /dev/null `
                                    then
                                    STATUS="OK"
                                    else
                                    STATUS="FAIL"
                                    fi

                                    echo "`date +'%D %H:%M:%S'` : $STATUS "
                                    echo "`date +'%D %H:%M:%S'` , $STATUS " >> $LOG
                                    sleep 30
                                    done





                                    share|improve this answer























                                      up vote
                                      0
                                      down vote










                                      up vote
                                      0
                                      down vote









                                      I'd do this, you'd get a log so you could run it over time and graph the result in excel.



                                      #!/bin/bash
                                      #Script to ping the IP after the gateway.

                                      LOG="ping.csv"
                                      TARGET="10.0.0.1"

                                      while :
                                      do
                                      if `ping -c1 $TARGET > /dev/null `
                                      then
                                      STATUS="OK"
                                      else
                                      STATUS="FAIL"
                                      fi

                                      echo "`date +'%D %H:%M:%S'` : $STATUS "
                                      echo "`date +'%D %H:%M:%S'` , $STATUS " >> $LOG
                                      sleep 30
                                      done





                                      share|improve this answer













                                      I'd do this, you'd get a log so you could run it over time and graph the result in excel.



                                      #!/bin/bash
                                      #Script to ping the IP after the gateway.

                                      LOG="ping.csv"
                                      TARGET="10.0.0.1"

                                      while :
                                      do
                                      if `ping -c1 $TARGET > /dev/null `
                                      then
                                      STATUS="OK"
                                      else
                                      STATUS="FAIL"
                                      fi

                                      echo "`date +'%D %H:%M:%S'` : $STATUS "
                                      echo "`date +'%D %H:%M:%S'` , $STATUS " >> $LOG
                                      sleep 30
                                      done






                                      share|improve this answer













                                      share|improve this answer



                                      share|improve this answer











                                      answered Jul 18 at 15:14









                                      Joe M

                                      5964




                                      5964




















                                          up vote
                                          -1
                                          down vote













                                          Pretty simple:



                                          $ ping -c 1 -W 3 www.go.org | grep -q "100% packet loss" && echo "Packet loss" || echo "Packet received"





                                          share|improve this answer

























                                            up vote
                                            -1
                                            down vote













                                            Pretty simple:



                                            $ ping -c 1 -W 3 www.go.org | grep -q "100% packet loss" && echo "Packet loss" || echo "Packet received"





                                            share|improve this answer























                                              up vote
                                              -1
                                              down vote










                                              up vote
                                              -1
                                              down vote









                                              Pretty simple:



                                              $ ping -c 1 -W 3 www.go.org | grep -q "100% packet loss" && echo "Packet loss" || echo "Packet received"





                                              share|improve this answer













                                              Pretty simple:



                                              $ ping -c 1 -W 3 www.go.org | grep -q "100% packet loss" && echo "Packet loss" || echo "Packet received"






                                              share|improve this answer













                                              share|improve this answer



                                              share|improve this answer











                                              answered Jul 18 at 14:39









                                              MysticDog

                                              12




                                              12






















                                                   

                                                  draft saved


                                                  draft discarded


























                                                   


                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function ()
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457014%2fis-there-a-ping-like-program-that-will-return-false-when-a-packet-is-lost%23new-answer', 'question_page');

                                                  );

                                                  Post as a guest













































































                                                  Popular posts from this blog

                                                  How to check contact read email or not when send email to Individual?

                                                  Bahrain

                                                  Postfix configuration issue with fips on centos 7; mailgun relay