Computer Hope
Microsoft => Microsoft DOS => Topic started by: olo131 on May 25, 2008, 09:47:14 AM
-
I have made a bat file for a speed test I use for work, I would like to know is there a way to have it copy to a text doc when it finishes automatically.
Here is my bat file.
@echo off
:A
echo.
echo CREATED FOR KNOLOGY SPEED TEST by: OLO 131
:B
echo.
echo Time and Date of Test
echo.
Date /t
Time /t
echo.
echo.
echo Type Number Then Enter
echo.
set choice=
set /p choice=CMTS
set /p choice=Port
echo.
echo Iperf Speed Test Server xx.x.xx.xxx
iperf -c xx.x.xx.xxx -r -w 64k -t 10 -i .5
echo.
echo.
echo.
echo.
echo Ping Iperf Server Test
ping xx.x.xx.xxx -n 10 -l 64k
echo.
echo.
echo DONE!
echo.
pause
goto B
-
can u explain more
what u want it to copy
-
Yes,
What I would like is when the test finishes to automatically create a text file named speed test and save on the desktop. I know I can just right click the screen and select all and enter to copy then open notepad then paste it there, I wondered if there was an easier way to automate the process.
Thank you in advance
James
-
its duable but u have to dublicate the commands not all of them ( to insure ur speed check)
lets assum that the file name is "ur Desktoppath/speed test.txt"
@echo off
set fname="ur Desktoppath/speed test.txt"
:A
echo.
echo. >fname
echo CREATED FOR KNOLOGY SPEED TEST by: OLO 131
echo CREATED FOR KNOLOGY SPEED TEST by: OLO 131 >>fname
:B
echo.
echo. >>fname
echo Time and Date of Test >>fname
echo.
echo. >>fname
Date /t
Date /t >>fname
Time /t
Time /t >>fname
echo.
echo. >>fname
echo.
echo. >>fname
echo Type Number Then Enter
echo Type Number Then Enter >>fname
echo.
echo. >>fname
set choice=
set /p choice=CMTS
echo CMTS>>fname
echo %choice%>>fname
set /p choice=Port
echo Port>>fname
echo %choice%>>fname
echo.
echo. >>fname
echo Iperf Speed Test Server xx.x.xx.xxx
echo Iperf Speed Test Server xx.x.xx.xxx >>fname
iperf -c xx.x.xx.xxx -r -w 64k -t 10 -i .5 >>fname //its not douplicated to not change the speed test
echo.
echo. >>fname
echo.
echo. >>fname
echo.
echo. >>fname
echo.
echo. >>fname
echo Ping Iperf Server Test
echo Ping Iperf Server Test >>fname
ping xx.x.xx.xxx -n 10 -l 64k >>fname //its not douplicated to not change the speed test
echo.
echo. >>fname
echo.
echo. >>fname
echo DONE!
echo DONE! >>fname
echo.
echo. >>fname
pause
echo x | pause >>fname
goto B
-
oh sorry
u should put fname between % like that
echo. >>%fname%
due to its a variable
-
First,
Thank you .bat_man for your help.
Now I'm getting this error and nothing is in the text file I would think the first couple of lines would copy, and I did add the >>%speed test.txt% in place of >>fname.
CREATED FOR KNOLOGY SPEED TEST by: OLO 131
Sun 05/25/2008
01:01 PM
Type Number Then Enter
CMTS
Port
Iperf Speed Test Server xx.x.xx.xxx
iperf: ignoring extra argument -- and
iperf: ignoring extra argument -- Settings\James
iperf: ignoring extra argument -- and
iperf: ignoring extra argument -- Robyn.DELL-DESKTOP\Desktop
Here is the code change
@echo off
set speed test.txt=C:\Documents and Settings\James and Robyn.DELL-DESKTOP\Desktop
:A
echo.
echo. >%speed test.txt%
echo CREATED FOR KNOLOGY SPEED TEST by: OLO 131
echo CREATED FOR KNOLOGY SPEED TEST by: OLO 131 >>%speed test.txt%
:B
echo.
echo. >>%speed test.txt%
echo Time and Date of Test >>%speed test.txt%
echo.
echo. >>%speed test.txt%
Date /t
Date /t >>%speed test.txt%
Time /t
Time /t >>%speed test.txt%
echo.
echo. >>%speed test.txt%
echo.
echo. >>%speed test.txt%
echo Type Number Then Enter
echo Type Number Then Enter >>%speed test.txt%
echo.
echo. >>%speed test.txt%
set choice=
set /p choice=CMTS
echo CMTS >>%speed test.txt%
echo %choice% >>%speed test.txt%
set /p choice=Port
echo Port>>%speed test.txt%
echo %choice% >>%speed test.txt%
echo.
echo. >>%speed test.txt%
echo Iperf Speed Test Server xx.x.xx.xxx
echo Iperf Speed Test Server xx.x.xx.xxx >>%speed test.txt%
iperf -c xx.x.xx.xxx -r -w 64k -t 10 -i .5 >>%speed test.txt%
echo.
echo. >>%speed test.txt%
echo.
echo. >>%speed test.txt%
echo.
echo. >>%speed test.txt%
echo.
echo. >>%speed test.txt%
echo Ping Iperf Server Test
echo Ping Iperf Server Test >>%speed test.txt%
ping xx.x.xx.xxx -n 10 -l 64k >>%speed test.txt%
echo.
echo. >>%speed test.txt%
echo.
echo. >>%speed test.txt%
echo DONE!
echo DONE! >>%speed test.txt%
echo.
echo. >>%speed test.txt%
pause
echo x | pause >>%speed test.txt%
goto B
-
he meant for you to use %fname% as a variable that you set when you start the batch, as in
set fname=speed test.txt
and then use %fname% as he described, not %speed test.txt%.
-
the variable name cant have spaces in its name for that u have to set the variable fname as this example
set fname="C:\Documents and Settings\James and Robyn.DELL-DESKTOP\Desktop\speed test.txt"
instead of this
set speed test.txt=C:\Documents and Settings\James and Robyn.DELL-DESKTOP\Desktop
i hope it works
-
.bat_man and BC_Programmer thank you for everything, it works, I have learn a lot form this site and will continue to be a member seeing this is my first.
Below are the results, now I have another question when the test runs I can not see the results of the speed test or the ping test the command runs in the window just not the result but they do show up in the .txt file. Is there a way to see the test results. IF not I thank you again.
James
CREATED FOR KNOLOGY SPEED TEST by: OLO 131
Time and Date of Test
Mon 05/26/2008
09:18 AM
Type Number Then Enter
CMTS
1
Port
1
Iperf Speed Test Server xx.x.xx.xxx
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 64.0 KByte
------------------------------------------------------------
------------------------------------------------------------
Client connecting to xx.x.xx.xxx, TCP port 5001
TCP window size: 64.0 KByte
------------------------------------------------------------
[1876] local xx.x.xx.xxx port 1247 connected with xx.x.xx.xxx port 5001
[ ID] Interval Transfer Bandwidth
[1876] 0.0- 0.5 sec 96.0 KBytes 1.57 Mbits/sec
[1876] 0.5- 1.0 sec 24.0 KBytes 393 Kbits/sec
[1876] 1.0- 1.5 sec 16.0 KBytes 262 Kbits/sec
[1876] 1.5- 2.0 sec 24.0 KBytes 393 Kbits/sec
[1876] 2.0- 2.5 sec 24.0 KBytes 393 Kbits/sec
[1876] 2.5- 3.0 sec 24.0 KBytes 393 Kbits/sec
[1876] 3.0- 3.5 sec 24.0 KBytes 393 Kbits/sec
[1876] 3.5- 4.0 sec 24.0 KBytes 393 Kbits/sec
[1876] 4.0- 4.5 sec 24.0 KBytes 393 Kbits/sec
[1876] 4.5- 5.0 sec 16.0 KBytes 262 Kbits/sec
[1876] 5.0- 5.5 sec 24.0 KBytes 393 Kbits/sec
[1876] 5.5- 6.0 sec 24.0 KBytes 393 Kbits/sec
[1876] 6.0- 6.5 sec 24.0 KBytes 393 Kbits/sec
[1876] 6.5- 7.0 sec 16.0 KBytes 262 Kbits/sec
[1876] 7.0- 7.5 sec 24.0 KBytes 393 Kbits/sec
[1876] 7.5- 8.0 sec 24.0 KBytes 393 Kbits/sec
[1876] 8.0- 8.5 sec 24.0 KBytes 393 Kbits/sec
[1876] 8.5- 9.0 sec 24.0 KBytes 393 Kbits/sec
[1876] 9.0- 9.5 sec 24.0 KBytes 393 Kbits/sec
[1876] 9.5-10.0 sec 24.0 KBytes 393 Kbits/sec
[ ID] Interval Transfer Bandwidth
[1876] 0.0-11.8 sec 536 KBytes 373 Kbits/sec
[1944] local xx.x.xx.xxx port 5001 connected with xx.x.xx.xxx port 51623
[ ID] Interval Transfer Bandwidth
[1944] 0.0- 0.5 sec 288 KBytes 4.72 Mbits/sec
[1944] 0.5- 1.0 sec 362 KBytes 5.93 Mbits/sec
[1944] 1.0- 1.5 sec 372 KBytes 6.10 Mbits/sec
[1944] 1.5- 2.0 sec 402 KBytes 6.59 Mbits/sec
[1944] 2.0- 2.5 sec 379 KBytes 6.21 Mbits/sec
[1944] 2.5- 3.0 sec 413 KBytes 6.77 Mbits/sec
[1944] 3.0- 3.5 sec 398 KBytes 6.52 Mbits/sec
[1944] 3.5- 4.0 sec 385 KBytes 6.31 Mbits/sec
[1944] 4.0- 4.5 sec 408 KBytes 6.68 Mbits/sec
[1944] 4.5- 5.0 sec 396 KBytes 6.49 Mbits/sec
[1944] 5.0- 5.5 sec 408 KBytes 6.68 Mbits/sec
[1944] 5.5- 6.0 sec 344 KBytes 5.63 Mbits/sec
[1944] 6.0- 6.5 sec 386 KBytes 6.33 Mbits/sec
[1944] 6.5- 7.0 sec 394 KBytes 6.45 Mbits/sec
[1944] 7.0- 7.5 sec 396 KBytes 6.49 Mbits/sec
[1944] 7.5- 8.0 sec 401 KBytes 6.56 Mbits/sec
[1944] 8.0- 8.5 sec 405 KBytes 6.63 Mbits/sec
[1944] 8.5- 9.0 sec 408 KBytes 6.68 Mbits/sec
[1944] 9.0- 9.5 sec 384 KBytes 6.28 Mbits/sec
[1944] 9.5-10.0 sec 413 KBytes 6.77 Mbits/sec
[ ID] Interval Transfer Bandwidth
[1944] 0.0-10.1 sec 7.63 MBytes 6.34 Mbits/sec
Ping Iperf Server Test
Pinging xx.x.xx.xxx with 64 bytes of data:
Reply from xx.x.xx.xxx: bytes=64 time=29ms TTL=59
Reply from xx.x.xx.xxx: bytes=64 time=33ms TTL=59
Reply from xx.x.xx.xxx: bytes=64 time=30ms TTL=59
Reply from xx.x.xx.xxx: bytes=64 time=29ms TTL=59
Reply from xx.x.xx.xxx: bytes=64 time=30ms TTL=59
Reply from xx.x.xx.xxx: bytes=64 time=30ms TTL=59
Reply from xx.x.xx.xxx: bytes=64 time=29ms TTL=59
Reply from xx.x.xx.xxx: bytes=64 time=29ms TTL=59
Reply from xx.x.xx.xxx: bytes=64 time=30ms TTL=59
Reply from xx.x.xx.xxx: bytes=64 time=30ms TTL=59
Ping statistics for xx.x.xx.xxx:
Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 29ms, Maximum = 33ms, Average = 29ms
DONE!
-
you could use 'start C:\path\to\results\text\file.txt' to start the txt file containing the results after the script has run.
Add it to the end of the batch file, just before your final 'exit'
hope it helps.
-
Ok I know it's been nearly a year but I have a question with my .bat file
Using the original command in this post is there any way to have the command restart its self every 15 min once it has been started or to have the command run 4 times in 1 hour.
Any combo of time will be fine if it can be done
Thanks
James
-
very old thead indeed.
sleep 15min --- use vbs sleep function
restart - call the batch itself --- %0
then to break, press CTRL-C
-
Or you could do a scheduled task?
Also, to do it on different computers without needing to change the code, the path to the desktop (on XP computers) is "%userprofile%\Desktop", can someone check that on a vista computer?
-
can someone check that on a vista computer?
Works on my Vista Laptop. :)
-
very old thead indeed.
sleep 15min --- use vbs sleep function
restart - call the batch itself --- %0
then to break, press CTRL-C
Thank you for answering my question and I thought using my old thread was better than starting a new one
I sorry I have not learn visual basic I just started with this one command. I'm not looking for someone to just fix my issue just point me in the right direction(and I think you have tried I just don't understand). I don't need a lot of fancy stuff and if I do my command is to simple for that.
Thank you for all your help
James
-
you can download the Windows 2000 resource kit utility sleep.exe
http://www.dynawell.com/download/reskit/microsoft/win2000/sleep.zip
Unzip the exe and put it somewhere on your PATH or in the same directory as the batch
syntax:
sleep N
where N is the number of seconds
so sleep 900 will wait 900 seconds (15 minutes)
-
It is funny I was just looking that up and I'm trying that now.
I'll post my results
-
I get an error
C:\Program Files\Windows Resource Kits\Tools\sleep.exe is not a valid Win32 application
I was also told to try this
PING -n 61 127.0.0.1>nul as s pause is this an OK option?
James
-
I get an error
C:\Program Files\Windows Resource Kits\Tools\sleep.exe is not a valid Win32 application
I was also told to try this
PING -n 61 127.0.0.1>nul as s pause is this an OK option?
James
What version of Windows are you using? Works fine on Windows 2000, XP. When did you last do a virus check? Is your antivirus up to date? because that message can be a sign of a previously existing infection.
Anyway the ping command you showed will wait for 1 minute (you add 1 to the number of seconds and put that number after ping -n)
-
I'm using XP But I have had a virus in in the past Thought I got rid of it
I thought the -n61 was the time of the delay but I much rather use the sleep option
James
-
I thought the -n61 was the time of the delay but I much rather use the sleep option
-n 61 means delay 60 seconds. -n 901 means delay 900 seconds.
-
thank you for you help
I went with the PING -n 61 127.0.0.1>nul command It was just simple.
thanks again
James
-
-n 61 means delay 60 seconds. -n 901 means delay 900 seconds.
But -n 10 -w 1000 will delay for 10 seconds (-w is the timeout).
-
now this sound useful
If I want my command to run for say 24hr and test every 30min it would look like this
PING -n 1801 -w 86401 127.0.0.1>nul
Correct??
-
now this sound useful
If I want my command to run for say 24hr and test every 30min it would look like this
PING -n 1801 -w 86401 127.0.0.1>nul
Correct??
-w is the timeout in miliseconds...
-n is the amount of times. If you use -w 1000, you don't need to add the extra 1 at the end.
Here is what I think you want to do...
@echo off
:loop
ping localhost -n 1800 -w 1000 > nul
COMMANDHERE
goto loop
-
Ok let's try this because I think your trying to help me
Here is my command I use for a network test.
@echo off
:A
echo.
echo CREATED FOR KNOLOGY SPEED TEST by: OLO 131
:B
echo.
echo Time and Date of Test
echo.
Date /t
Time /t
echo.
echo Iperf Speed Test Server xx.x.xx.xxx
iperf -c xx.x.xx.xxx -r -w 64k -t 20 -i 1
echo.
echo.
echo.
echo.
echo Ping Iperf Server Test
ping xx.x.xx.xxx -n 20 -l 64k
echo.
echo.
echo Trace Route Iperf Server
tracert xx.x.xx.xxx
echo.
echo.
echo DONE!
echo _______________________________________ __________________________________
echo.
PING -n 1801 -w 86400001 127.0.0.1>nul
goto B
SO.....will this work for a 24hr test testing every 30min and then stopping but not closing the open window so I can save the test??
I have not run this test I just want you to look at it and see if the command fits
James
-
OK let's try this because I think your trying to help me
Here is my command I use for a network test.
@echo off
:A
echo.
echo CREATED FOR KNOLOGY SPEED TEST by: OLO 131
:B
echo.
echo Time and Date of Test
echo.
Date /t
Time /t
echo.
echo Iperf Speed Test Server xx.x.xx.xxx
iperf -c xx.x.xx.xxx -r -w 64k -t 20 -i 1
echo.
echo.
echo.
echo.
echo Ping Iperf Server Test
ping xx.x.xx.xxx -n 20 -l 64k
echo.
echo.
echo Trace Route Iperf Server
tracert xx.x.xx.xxx
echo.
echo.
echo DONE!
echo _______________________________________ __________________________________
echo.
PING -n 1801 -w 86400001 127.0.0.1>nul
goto B
SO.....will this work for a 24hr test testing every 30min and then stopping but not closing the open window so I can save the test??
I have not run this test I just want you to look at it and see if the command fits
James
I always put where I'm pinging right after PING (I'm not sure it works otherwise)...and I would put a CLS between PING and GOTO B. But I reccommend you look in my previous post.
-w is the timeout in milliseconds...
-n is the amount of times. If you use -w 1000, you don't need to add the extra 1 at the end.
Here is what I think you want to do...
@echo off
:loop
ping localhost -n 1800 -w 1000 > nul
COMMANDHERE
goto loop
The above should loop every 30 minutes.
-
I will give it a try
Thanks
James
-
pinging for 15minutes seems like not a good idea, could have some side-effect which i am not sure of. besides ping delay is not really accurate. that's why in the first place i suggest using vbs sleep function instead of ping.
if you just need to delay for 4-5 seconds once in a while, i would have suggest you using ping instead of vbs sleep.
the code:
>$sleep.vbs echo wsh.sleep 900000
cscript//nologo $sleep.vbs
900000 is in miliseconds, or 900seconds=15minutes.
-
olo131, you need to investigate why the sleep command is not working.
-
pinging for 15minutes seems like not a good idea, could have some side-effect which i am not sure of. besides ping delay is not really accurate. that's why in the first place i suggest using vbs sleep function instead of ping.
if you just need to delay for 4-5 seconds once in a while, i would have suggest you using ping instead of vbs sleep.
the code:
>$sleep.vbs echo wsh.sleep 900000
cscript//nologo $sleep.vbs
900000 is in miliseconds, or 900seconds=15minutes.
True, but if you are using it on computers which may not have sleep, ping is your best (only) choice. Although it seems fairly accurate...not to nano seconds, but I've made a stopwatch in batch...almost...
-
True, but if you are using it on computers which may not have sleep, ping is your best (only) choice. Although it seems fairly accurate...not to nano seconds, but I've made a stopwatch in batch...almost...
All Windows computers have VBScript, and can use sleep.vbs.
-
I did look for a virus and Norton said I'm Clean but that dosen't mean everything. I do like to download games and the cracks may have something looming around
I use this command for work (I Work for a cable co) to check for network problems and Iperf is the program they offer but I got tired of typing it in to a command line so I started this file.
I ran a test last night with the command and it worked perfectly until I needed to stop. I used CTL-C it asked if I wanted to terminate Y or N of course I said yes......and window gone. That was my only mistake next time I will say No then I can copy my results before closing the window.
I will give this out to others in my company so I just want to get it right as I can.
>$sleep.vbs echo wsh.sleep 900000
cscript//nologo $sleep.vbs
This worked grate is there a way to tell it to stop after 24hrs but not close the window? Isn't there a timeout command I can try. In need to copy it into a text doc to be emailed.
Again thank you
James
-
Hey Reno,
The code you posted put the command to sleep just as you said but it never recovers. I even shorten the time.
When I tested it earlier I did not give it enough time to see if it would run the next test. It is just what I looking for.
any ideas
James
-
is there a way to tell it to stop after 24hrs but not close the window? Isn't there a timeout command I can try. In need to copy it into a text doc to be emailed.
The code you posted put the command to sleep just as you said but it never recovers. I even shorten the time.
the code is only for sleep, so after sleep, you have to use some sort of restarting, eg. goto statement, call, restart the batch %0, etc
24 hours stop:15minutes = 4x / hour
24hr x 4x = 96x
not exactly 24 hours, roughly around 24hours + 96 * (time needed to run batch file)
@echo off
echo.
echo CREATED FOR KNOLOGY SPEED TEST by: OLO 131
>$sleep.vbs echo wsh.sleep 900000
for /l %%a in (1 1 96) do (
call:B
cscript//nologo $sleep.vbs
)
echo 24hrs!! do copy here..
goto:eof
:B
echo.
echo Time and Date of Test
echo.
Date /t
Time /t
echo.
echo Iperf Speed Test Server xx.x.xx.xxx
iperf -c xx.x.xx.xxx -r -w 64k -t 20 -i 1
echo.
echo.
echo.
echo.
echo Ping Iperf Server Test
ping xx.x.xx.xxx -n 20 -l 64k
echo.
echo.
echo Trace Route Iperf Server
tracert xx.x.xx.xxx
echo.
echo.
echo DONE!
echo _______________________________________ __________________________________
echo.
-
Reno,
You are the man I ran my test for 24hr worked perfectly now I will do a search for a stop command.
Thank you again, Reno and everyone who helped me
James