+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, Ping Script in Coding and Web Development; hi, I am looking for a script that will ping an ip address. If it does not get a reply ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,374
    Thank Post
    906
    Thanked 1,811 Times in 1,559 Posts
    Blog Entries
    12
    Rep Power
    468

    Ping Script

    hi,

    I am looking for a script that will ping an ip address. If it does not get a reply i would then like it to run a batch file

    Can anyone help please?

    Thanks

    Z

  2. #2


    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,317
    Thank Post
    131
    Thanked 355 Times in 293 Posts
    Blog Entries
    4
    Rep Power
    142
    Code:
    ping -n 1 -l 1 targetip
    if %errorlevel%==0 echo Host is up!
    if %errorlevel%==1 goto DOWN
     
    :DOWN
    Do stuff here
    And more stuff
    Should work.

  3. #3

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,374
    Thank Post
    906
    Thanked 1,811 Times in 1,559 Posts
    Blog Entries
    12
    Rep Power
    468
    Quote Originally Posted by jamesb View Post
    Code:
    ping -n 1 -l 1 targetip
    if %errorlevel%==0 echo Host is up!
    if %errorlevel%==1 goto DOWN
     
    :DOWN
    Do stuff here
    And more stuff
    Should work.

    Is that a batch file?

    Thanks

  4. #4


    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,317
    Thank Post
    131
    Thanked 355 Times in 293 Posts
    Blog Entries
    4
    Rep Power
    142
    Batch code, yep. Change targetip for whichever IP address you're wanting to check, and put the code you want to execute if it fails under the label.

    In fact, thinking about it, this might be better -

    Code:
    ping -n 1 -l 1 targetip
    if %errorlevel%==0 goto END
     
    Do stuff here
    And more stuff
     
    :END

  5. Thanks to jamesb from:

    FN-GM (22nd April 2009)

  6. #5
    pauljonze's Avatar
    Join Date
    May 2008
    Location
    Staffs
    Posts
    86
    Thank Post
    17
    Thanked 22 Times in 15 Posts
    Rep Power
    23
    Could even use

    ping -n 1 -l 1 targetip>NULL:

    to supress feedback?

  7. #6

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,249
    Thank Post
    1,061
    Thanked 1,070 Times in 626 Posts
    Rep Power
    741
    Use my No ping script & edit it slightly...

    No Ping

    E-mail me if you want the source.



SHARE:
+ Post New Thread

Similar Threads

  1. Script to check various ping results
    By localzuk in forum Scripts
    Replies: 6
    Last Post: 30th March 2009, 11:15 PM
  2. [Website] ping.fm
    By russdev in forum Jokes/Interweb Things
    Replies: 3
    Last Post: 23rd June 2008, 08:01 PM
  3. script to ping IP adresses of Access Points
    By projector1 in forum Scripts
    Replies: 12
    Last Post: 16th May 2008, 08:47 PM
  4. No Ping Script
    By mattx in forum Scripts
    Replies: 16
    Last Post: 22nd February 2008, 09:03 PM
  5. Anybody used PING?
    By sqdge in forum Windows
    Replies: 11
    Last Post: 10th August 2007, 08:25 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •