+ 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
    15,821
    Thank Post
    873
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444

    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,168
    Thank Post
    98
    Thanked 319 Times in 261 Posts
    Blog Entries
    4
    Rep Power
    112
    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
    15,821
    Thank Post
    873
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444
    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,168
    Thank Post
    98
    Thanked 319 Times in 261 Posts
    Blog Entries
    4
    Rep Power
    112
    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
    22
    Could even use

    ping -n 1 -l 1 targetip>NULL:

    to supress feedback?

  7. #6

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740
    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, 10:15 PM
  2. [Website] ping.fm
    By russdev in forum Jokes/Interweb Things
    Replies: 3
    Last Post: 23rd June 2008, 07:01 PM
  3. script to ping IP adresses of Access Points
    By projector1 in forum Scripts
    Replies: 12
    Last Post: 16th May 2008, 07:47 PM
  4. No Ping Script
    By mattx in forum Scripts
    Replies: 16
    Last Post: 22nd February 2008, 08:03 PM
  5. Anybody used PING?
    By sqdge in forum Windows
    Replies: 11
    Last Post: 10th August 2007, 07: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
  •