Computer Hope
Microsoft => Microsoft DOS => Topic started by: SooPa_fLy on November 01, 2006, 03:46:02 AM
-
Hey guys,
Well I have searched high and low and tried everything but cannot get batch file to ping in a constant loop.
Basically I want to ping an ip constantly to keep a connection going (no not ping flood any1 :P)
Here is what I have so far....
pause
@echo off
for /f "tokens=*" %%I in (C:\DocumentsandSettings\Matt\MyDocuments\Matt\iplist.txt) do call :pinger %%I
goto :eof
:pinger
echo %TIME% >> pingLOG
ping %1 >> pingLOG
:: DONE
Please have a look and advise me where I may have gone wrong or what I can do to make this work.
It would be greatly appreciated as I am at my wits end.
Cheers in Advance
SooPa_fLy
-
This worked when z.txt contained a few ip addresses, one to a line.
Lots of luck with your disk space if you run this for a long time. LOG will grow.
Mac
@echo off
cls
:loop
for /f %%I in (z.txt) do (
echo Pinging %%I
echo %TIME% >> z.log
ping %%I >> z.log
)
goto loop
-
How about:
ping -t 1.2.3.4
Replace 1.2.3.4 with the IP address that you really want to ping.
-
Evil, GuruGary! LOL
That will keep one IP busy. He could use START to get them all going.
But I don't think he wants THAT many pings. He said
Basically I want to ping an ip constantly to keep a connection going
So he needs to ping every minute or 10 minutes, etc., not every 10ms. If you know a way to do the QBasic equivalent of SLEEP 10, suggest that.
Mac
-
would a simple way to do this be :
:ping
ping x.x.x.x
wait 10
goto :ping
-
Basically my iplist.txt is going to have a few different ips so I don't give 1 website the sh!ts by constantly pinging them.
I am looking to send a ping out every few minutes to keep the connection established. while I try to figure out what another problem is.
Cheers for the replies guys.
-
The "wait 10" idea doesn't work in WindowsNT. WAIT is not a command.
However, if you just want to stall to give hosts a break, try this
Use my suggested BAT file (change filenames as desired)
In the TXT file, put your real sites you want to ping and then follow by a zillion instances of your own IP address.
By the time it gets through trying to ping them, some time would have elapsed.
-
Qbasic cheers for that I will give it a try.
What about this
:ping
ping -n 100 127.x.x.x
goto :ping
I have been pinging a mates website as he does not mind as I am having trouble making it find the txt file with the iplist.
-
At what interval do you want to ping your iplist.txt? Do you want to wait between each ping? Or ping everything in your iplist.txt, and then delay?
Try this for once every minute, delay between each ping:
@echo off
:Start
for /f %%a in ("C:\Documents and Settings\Matt\My Documents\Matt\iplist.txt") do (
echo %TIME% >> pingLOG
ping %%a >> pingLOG
ping -n 61 localhost >NUL
)
goto :Start
-
If you are just looking for a result without the nuts & bolts then Connection Keeper will do it all for you.
http://www.gammadyne.com/conkeep.htm
Of course you will learn a lot more talking to these scary dos guys. Hi fellas! :D
-
would a simple way to do this be :
:ping
ping x.x.x.x
wait 10
goto :ping
use the "sleep" command from the [RK]
uli
-
I would swear I just posted this, but I don't see it.
A bat file which can be named SLEEP.BAT and put in your path
@echo off
if x%1==x (
echo Usage: SLEEP n [where n is the number of seconds]
goto Adios
)
if not %1==NewCall %0 NewCall %1 >nul
ping -n %2 localhost
:Adios
SLEEP 10 will sleep 10 seconds.
Based on GuruGary's ping -n 10 localhost >nul
which doesn't work on windowsNT for unknown reason
Mac
-
Cheers for the tips guys. I will give them a go and see how it goes.
We have been running a ping utility but it is a trial and my manager wanted a bacth file.
Thanks again guys
cheers :)