User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Legacy and Other Languages section within the Software Development category of DaniWeb, a massive community of 426,198 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,844 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Legacy and Other Languages advertiser: Programming Forums
Views: 21493 | Replies: 29
Reply
Join Date: May 2005
Posts: 228
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

DOS Batch command to ping network IP

  #1  
Mar 27th, 2007
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 7:31 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2005
Posts: 228
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: DOS Batch command to ping network IP

  #2  
Apr 3rd, 2007
*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:

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?
Reply With Quote  
Join Date: Aug 2005
Posts: 4,782
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 319
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: DOS Batch command to ping network IP

  #3  
Apr 7th, 2007
>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?
I'm not a programmer. My attitude starts with ignorance, holds steady at conversation, and ends with a trip to the hospital. Get used to it.
Reply With Quote  
Join Date: May 2005
Posts: 228
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: DOS Batch command to ping network IP

  #4  
Apr 7th, 2007
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.
Reply With Quote  
Join Date: Jan 2007
Location: Oxfordshire, England
Posts: 307
Reputation: DenisOxon is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 14
DenisOxon's Avatar
DenisOxon DenisOxon is offline Offline
Posting Whiz

Re: DOS Batch command to ping network IP

  #5  
May 13th, 2007
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.
Reply With Quote  
Join Date: May 2005
Posts: 228
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: DOS Batch command to ping network IP

  #6  
May 13th, 2007
Originally Posted by DenisOxon View Post
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.
Reply With Quote  
Join Date: Apr 2005
Location: Old Hampshire, Old England (LOL)
Posts: 11,937
Reputation: jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough 
Rep Power: 30
Solved Threads: 268
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Microsoft Fanboy

Re: DOS Batch command to ping network IP

  #7  
May 13th, 2007
i suppose you could do it as a script instead of a batch file
TRY MY SUGGESTIONS AT YOUR OWN RISK!
james.bennet1@ntlworld.com
Reply With Quote  
Join Date: Jan 2007
Location: Oxfordshire, England
Posts: 307
Reputation: DenisOxon is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 14
DenisOxon's Avatar
DenisOxon DenisOxon is offline Offline
Posting Whiz

Re: DOS Batch command to ping network IP

  #8  
May 13th, 2007
Originally Posted by nathanpacker View Post
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
Reply With Quote  
Join Date: May 2005
Posts: 228
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: DOS Batch command to ping network IP

  #9  
May 13th, 2007
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.
Reply With Quote  
Join Date: Jan 2007
Location: Oxfordshire, England
Posts: 307
Reputation: DenisOxon is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 14
DenisOxon's Avatar
DenisOxon DenisOxon is offline Offline
Posting Whiz

Re: DOS Batch command to ping network IP

  #10  
May 14th, 2007
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Legacy and Other Languages Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Legacy and Other Languages Forum

All times are GMT -4. The time now is 7:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC