Computing.Net > Forums > Programming > Using ping to provide a delay

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Using ping to provide a delay

Reply to Message Icon

Name: klint
Date: February 1, 2008 at 02:20:59 Pacific
OS: Windows XP SP2
CPU/Ram: Pentium 4
Product: IBM
Comment:

I tried using the ping command to provide a delay in a batch file (a similar function to the sleep.exe that comes with the Windows Resource Kit, except that ping is available on all Windows XP machines.)

PING 1.1.1.1 -n 1 -w 60000

This has been suggested in many places on the web as a way of waiting for 60 seconds. However, when I try it, it comes back immediately with the following error:

Reply from XXX: Destination host unreachable.

(where XXX is my localhost IP address.)

Any idea why this is happening on my PC and obviously is not happening on other people's, otherwise they wouldn't have suggested this technique?

(I know I can use "ping -n 61 127.0.0.1 >nul" as a workaround, but was just wondering why the above didn't work.)



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: February 1, 2008 at 05:17:10 Pacific
Reply:

check your HOSTS file



=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: Razor2.3
Date: February 1, 2008 at 06:29:47 Pacific
Reply:

See, this is why I prefer to make a sleep.vbs.


0

Response Number 3
Name: tonysathre
Date: February 1, 2008 at 14:54:15 Pacific
Reply:

"check your HOSTS file"

I second that.


0

Response Number 4
Name: klint
Date: February 1, 2008 at 15:22:07 Pacific
Reply:

My hosts file just contains 127.0.0.1 localhost and a couple of other irrelevant mappings of hostnames on our Intranet. What exactly were you thinking of, that the problem could possibly be caused by my hosts file? It's just a mapping of hostnames to ip addresses isn't it? And when you supply an IP address to ping, it don't think it even looks at the hosts file at all. Have I overlooked something?


0

Response Number 5
Name: tonysathre
Date: February 1, 2008 at 15:46:19 Pacific
Reply:

"And when you supply an IP address to ping, it don't think it even looks at the hosts file at all"

Actually, that's the first place it looks.

Are you using DHCP on your LAN? If you're not, I would suggest adding whatever static IP you have set to your HOSTS file, pointing it at localhost.


0

Related Posts

See More



Response Number 6
Name: klint
Date: February 1, 2008 at 17:39:29 Pacific
Reply:

Tony,

Can you elaborate on "that's the first place it looks", as I must have misunderstood the role of the hosts file. I thought it was where it would look if you supplied a hostname, because it needs to convert it to an IP address. But if you supply a numeric IP address to begin with, what extra information does it need from the hosts file?

I don't use DHCP at work (where the ping returns immediately with the error message). I do use DHCP at home where the ping gives the required time delay. I don't have any mention of the IP address 1.1.1.1 in either hosts file. But then I don't understand how that would make any difference.


0

Response Number 7
Name: tonysathre
Date: February 1, 2008 at 18:31:47 Pacific
Reply:

Sorry, ya you are correct. After re-reading your original post I see that. rDNS starts with your local DNS server, or ISP's DNS server, not the hosts file.

It sounds like a routing issue to me. The router could not find the network, 1.x.x.x.


0

Response Number 8
Name: Razor2.3
Date: February 1, 2008 at 18:32:20 Pacific
Reply:

klint: I thought it was where it would look if you supplied a hostname, because it needs to convert it to an IP address.
You are correct. Everyone else is crazy. CRAZY, I TELL YOU! But us? We're not crazy. No, not crazy at all... (You can verify this by either watching PING.EXE's stack, or by using PROCMON.EXE.)

You'd probably gain more useful information by looking at the ROUTE PRINT command.

EDIT: VVV He admits! CRAZY! VVV


0

Response Number 9
Name: tonysathre
Date: February 1, 2008 at 18:43:17 Pacific
Reply:

"Everyone else is crazy"

I'm not that crazy, just wrong on occasion. Lol


0

Response Number 10
Name: klint
Date: February 3, 2008 at 05:32:56 Pacific
Reply:

Thanks, I'm not a networking expert but the ROUTE command you suggest seems worth trying. I'll need to spend some time to understand it.


0

Response Number 11
Name: Razor2.3
Date: February 3, 2008 at 10:22:34 Pacific
Reply:

For reference, here's what a generic Windows route table looks like:

Sun 02/03/2008 13:20:32.26
E:\Documents and Settings>route print

===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 0c 41 64 70 96 ...... Wireless-G PCI Adapter - Packet Scheduler Miniport
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.5 25
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.1.0 255.255.255.0 192.168.1.5 192.168.1.5 25
192.168.1.5 255.255.255.255 127.0.0.1 127.0.0.1 25
192.168.1.255 255.255.255.255 192.168.1.5 192.168.1.5 25
224.0.0.0 240.0.0.0 192.168.1.5 192.168.1.5 25
255.255.255.255 255.255.255.255 192.168.1.5 192.168.1.5 1
Default Gateway: 192.168.1.1
===========================================================================
Persistent Routes:
None


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Using ping to provide a delay

Using parameters to rename a file www.computing.net/answers/programming/using-parameters-to-rename-a-file/15005.html

using java to serach a text file www.computing.net/answers/programming/using-java-to-serach-a-text-file/11554.html

VBScript to launch a secure website login www.computing.net/answers/programming/vbscript-to-launch-a-secure-website-login/20230.html