FN-GM Posted April 22, 2009 Posted April 22, 2009 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
jamesb Posted April 22, 2009 Posted April 22, 2009 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.
FN-GM Posted April 22, 2009 Author Posted April 22, 2009 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
jamesb Posted April 22, 2009 Posted April 22, 2009 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 - ping -n 1 -l 1 targetip if %errorlevel%==0 goto END Do stuff here And more stuff :END 1
pauljonze Posted April 22, 2009 Posted April 22, 2009 Could even use ping -n 1 -l 1 targetip>NULL: to supress feedback?
mattx Posted April 22, 2009 Posted April 22, 2009 Use my No ping script & edit it slightly... No Ping E-mail me if you want the source.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now