943,918 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Mar 27th, 2007
0

DOS Batch command to ping network IP

Expand Post »
Hey, I'm a complete noob to batch commands. I just found that they might be somewhat useful for some stuff I'm doing, so I thought I'd try them out.

Anyway, I've got a batch file that calls a program called Poweroff to turn on a pc on my network via WOL (wake on lan).

Here is the code:
CLS
@ECHO ON
poweroff wol -ip 192.168.0.3 -subnet 255.255.255.0 -mac 0xxxx00xxxxx
call wait 90
CLS
EXIT

As you can see, I'm calling a script called wait.bat, that simply pauses the script for 90 seconds to make sure the box has come out of hibernate before I continue processing commands. But I would like it to be more efficient. Rather than just waiting 90 seconds, and then continuing on, I would like to ping 192.168.0.3, and wait till there is a reply, and then go on. That way I can make sure the box is up before continuing.

Anyone know how to check the ping reply to make sure it is getting a reply before continuing on?
Thanks.

edit: I replaced the MAC address for security purposes.
Last edited by nathanpacker; Mar 27th, 2007 at 8:31 pm.
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
nathanpacker is offline Offline
234 posts
since May 2005
Apr 4th, 2007
0

Re: DOS Batch command to ping network IP

*BUMP*
No ideas? Surely it's a simple solution. I've googled it to death but can't find anything. A batch command that could confirm whether a ping comes back successfully would be fairly useful, no? Say:

Quote ...
PING 192.168.0.3
IF Reply {
do this
}
else {
do this
}
But how do I check for the reply, and pass it to the IF statement?
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
nathanpacker is offline Offline
234 posts
since May 2005
Apr 7th, 2007
0

Re: DOS Batch command to ping network IP

>Surely it's a simple solution

I don't think so, I could only think of a way to get the status back using code i.e getProcessState. Unless someone knows better?
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Apr 7th, 2007
0

Re: DOS Batch command to ping network IP

Well thanks for the reply anyway. I think I might have something figured out. As soon as I do, I'll update this thread.
Thanks.
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
nathanpacker is offline Offline
234 posts
since May 2005
May 13th, 2007
0

Re: DOS Batch command to ping network IP

If you do a ping -t 192.168....

Then it will continue pinging until you hit CTL C - you will therefore see when it comes up and continue when you are ready.
Reputation Points: 22
Solved Threads: 19
Posting Whiz
DenisOxon is offline Offline
345 posts
since Jan 2007
May 13th, 2007
0

Re: DOS Batch command to ping network IP

Click to Expand / Collapse  Quote originally posted by DenisOxon ...
If you do a ping -t 192.168....

Then it will continue pinging until you hit CTL C - you will therefore see when it comes up and continue when you are ready.
Yeah, that's great, except you can't do that in a batch script. Thanks for the idea though. I haven't had time to look further into this yet, but as soon as I do, I'll let you know how it goes.
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
nathanpacker is offline Offline
234 posts
since May 2005
May 13th, 2007
0

Re: DOS Batch command to ping network IP

i suppose you could do it as a script instead of a batch file
Moderator
Featured Poster
Reputation Points: 1784
Solved Threads: 574
Moderator
jbennet is offline Offline
16,520 posts
since Apr 2005
May 13th, 2007
0

Re: DOS Batch command to ping network IP

Yeah, that's great, except you can't do that in a batch script. Thanks for the idea though. I haven't had time to look further into this yet, but as soon as I do, I'll let you know how it goes.

Sorry I thought you saw it run, so you could cancel it
Reputation Points: 22
Solved Threads: 19
Posting Whiz
DenisOxon is offline Offline
345 posts
since Jan 2007
May 13th, 2007
0

Re: DOS Batch command to ping network IP

That's ok. Yeah, if and when I do it, it will be going in the middle of the night. But as of right now, I've kind of had to put it on hold.
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
nathanpacker is offline Offline
234 posts
since May 2005
May 14th, 2007
0

Re: DOS Batch command to ping network IP

As it will run in middle of night, if it always works with 90 seconds delay then I would go with that.

Just had a thought - when it is up and running can you test for the exstance of a file (have a file used as a marker file that is never deleted) If so you just keep testing for it. Make sure you have an 8.3 name for it.
Reputation Points: 22
Solved Threads: 19
Posting Whiz
DenisOxon is offline Offline
345 posts
since Jan 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Legacy and Other Languages Forum Timeline: Euphoria
Next Thread in Legacy and Other Languages Forum Timeline: Lisp question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC