Forum Home
Press F1
 
Thread ID: 21234 2002-06-21 01:13:00 How do you make a Ping batch file? Susan B (19) Press F1
Post ID Timestamp Content User
55667 2002-06-21 01:13:00 I often need to ping a website to see if it is working OK and want a ping batch file to make it easier. What should be in it? At the moment I've got the following example and it doesn't appear to work:

@echo off
cd \
ping www.pcworld.co.nz


Have also tried just ping www.pcworld.co.nz but it won't stop then!

Any ideas?
Susan B (19)
55668 2002-06-21 01:31:00 Susan,
The PING command options/switches are here:
and further down I have stuck a quick example (without any switches)
Cheers, Babe.

Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
[-r count] [-s count] [[-j host-list] | [-k host-list]]
[-w timeout] target_name

Options:
-t Ping the specified host until stopped.
To see statistics and continue - type Control-Break;
To stop - type Control-C.
-a Resolve addresses to hostnames.
-n count Number of echo requests to send.
-l size Send buffer size.
-f Set Don't Fragment flag in packet.
-i TTL Time To Live.
-v TOS Type Of Service.
-r count Record route for count hops.
-s count Timestamp for count hops.
-j host-list Loose source route along host-list.
-k host-list Strict source route along host-list.
-w timeout Timeout in milliseconds to wait for each reply.

eg for me i have a pinger.cmd file very simple looks like:

@echo off
ping %1

The %1 is the host parameter passed when running the command e.g.

PINGER www.idg.co.nz

Could also do something like:
@echo off
:reping
ping %1
sleep 60
goto reping

In the second example the sleep command is used to 'wait' for a minute
before repinging the host passed as parameter 1
Babe Ruth (416)
55669 2002-06-21 01:49:00 Leave off the www. Ping the host - pcworld.co.nz, microsoft.com, etc.

You can ping from the command prompt which will work fine now. If you want a batch file that will work from Run on the start menu try:

ping %1
pause

If you call it pingbat.bat then from run, you can enter
pingbat host - eg pingbat microsoft.com
and it will ping the site and wait for the key press before exiting.
Brent P (198)
55670 2002-06-21 01:55:00 excuse me people, but why have a batch file to execute a command that is four letters long, replacing it with pingbat (7 letters!) I would just open a prompt and type ping pcworld.co.nz. Why do the same thing then type bingbat pcworld.co.nz???

Silly if you ask me.

G P
Graham Petrie (449)
55671 2002-06-21 02:11:00 Although Graham most of the time I use a PING command I am also using a number of the options/switches (usually the same ones) in which case a CMD file and pass the address as the param is great, also have the output sent to a file or grep'd. But everyone to their own.

Just a nickels worth,
Cheers, babe.
Babe Ruth (416)
55672 2002-06-21 02:30:00 Thanks for replying everyone.

The reason I don't use ping from the run box is because the results flash by so quick and the window doesn't hang around long enough for me to read it. Someone once told me to go to a DOS window and run from there, which works fine. I'm just sick of opening a DOS to run it everytime I need it.

Babe, I've created and run a pinger.cmd file but get told "file not found" and can't run it. Same with pinger.bat now, whereas the bat file opened before even though the ping didn't work. ?:|

I notice that *.cmd files aren't associated with anything and can't see MS-DOS in the list of files to open with.

I'm stumped now!
Susan B (19)
55673 2002-06-21 02:48:00 i just made a file entitled test.bat. It contains two lines of text.

@echo off
ping www.pcworld.co.nz

In a command window I type test [enter] and it works perfectly.

No idea Susan

G P
Graham Petrie (449)
55674 2002-06-21 03:09:00 Hi Susan

I often need to use Ping so I keep a DOS box shortcut on my desktop. I agree with other repondents that a batchfile is an unnecessary complication.

To repeat a ping, press F3/enter, to get rid of a screen full of pings type cls/enter, and to go back to windows type exit/enter.

Sweet!

Cheers

Billy 8-{) ;) :)
Billy T (70)
55675 2002-06-21 03:12:00 Why bother with a batch file.

For such a simple task it is much more convenient to create a shortcut.

When on the desktop, right-click and select to have a new shortcut.
Set it to point to "ping www.pcworld.co.nz" and all is done.

For easiest use place this short cut in the quick launch area.
-=JM=- (16)
55676 2002-06-21 03:27:00 Susan,
Sorry I forgot to ask what version/type Windows you are running...

The .CMD files are batch files for WinNT/2000/XP and .BAT files for all Windows versions.

If you are running NT/2000/XP you could have a command like:

cmd.exe /x /c ping pressf1.co.nz & pause

which could be in a shortcut of your choosing.

Cheers, Babe.
Babe Ruth (416)
1 2 3 4 5 6