ping mutiple IPs at once AIX script

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf ping mutiple IPs at once AIX script

  • Creator
    Topic
  • #51711
    Hongle Sun
    Participant

      Do anyone out there have shell script to ping mutiple hostname/ IPs? Thank in advance

    Viewing 2 reply threads
    • Author
      Replies
      • #71388
        David Barr
        Participant

          Code:

          #!/bin/sh
          ping host1
          ping host2

          Sorry, I couldn’t resist.

        • #71389
          Chris Williams
          Participant

            I can’t resist either. Try this so it doesn’t ping forever:

            Code:

            #!/bin/sh
            ping -c count host1
            ping -c count host2


            Cheers.

          • #71390
            Robert Milfajt
            Participant

              After all it is Friday…   8)

              Code:

              #!/bin/ksh
              HOST1=$(ping -c 5 host1 | grep “bytes from” | wc -l)
              HOST2=$(ping -c 5 host2 | grep “bytes from” | wc -l)
              [[ $HOST1 -eq 5 ]] && [[$HOST2 -eq 5]] && echo “All OK” && exit 0
              echo “Some Connection Failure”
              exit 1

              Robert Milfajt
              Northwestern Medicine
              Chicago, IL

          Viewing 2 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.