|
Answer» Hi,
what i am trying to achieve, is to measure network performance using a batch file The batch file copies a test file (1meg.test) from from a central server to the c:\TEMP directory on a bunch of COMPUTERS. by looping through a list (list.txt) of computers at remote sites to calculate the AMOUNT of time taken to copy the file to each computer, then outputs the results to a txt file (timer.txt)
i have two batch files the first (run.bat) calls the main batch file and reads from the list.txt
---RUN.BAT---
FOR /f %%u IN (list.txt) DO call c:\temp\timer.bat %%u >> c:\temp\timer.txt
-------------------------------------------------------------------------- which then should then run the second batch file (timer.bat)
---timer.bat---
@echo off FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Second /Format:table ^| findstr /r "."') DO ( set Milisecond=%time:~9,2% set Day=%%A set Hour=%%B set Minute=%%C set Second=%%D ) set /a Start=%Day%*8640000+%Hour%*360000+%Minute%*6000+%Second%*100+%Milisecond% copy c:\temp\1meg.test \\%comp%\c$\temp [this is where i am having a problem]
FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Second /Format:table ^| findstr /r "."') DO ( set Day=%%A set Hour=%%B set Minute=%%C set Second=%%D ) set Milisecond=%time:~9,2% set /a End=%Day%*8640000+%Hour%*360000+%Minute%*6000+%Second%*100+%Milisecond% set /a Diff=%End%-%Start% set /a DiffMS=%Diff%%%100 set /a Diff=(%Diff%-%DiffMS%)/100 set /a DiffSec=%Diff%%%60 set /a Diff=(%Diff%-%Diff%%%60)/60 set /a DiffMin=%Diff%%%60 set /a Diff=(%Diff%-%Diff%%%60)/60 set /a DiffHrs=%Diff% :: format with leading zeroes if %DiffMS% LSS 10 set DiffMS=0%DiffMS!% if %DiffSec% LSS 10 set DiffMS=0%DiffSec% if %DiffMin% LSS 10 set DiffMS=0%DiffMin% if %DiffHrs% LSS 10 set DiffMS=0%DiffHrs% echo %DiffHrs%:%DiffMin%:%DiffSec%.%DiffMS% >> c:\temp\timer.txt ---------------------------------------------------------------------------
---list.txt--- computer1 computer2 computer3 computer4 computer5 .etc..
the output that i am trying to get is something like ----output.txt------ computer1 00.200 sec computer2 00.300 sec computer3 00.400 sec etc ....
the time function calculates correctly my problem is getting the batch to loop through the list of remote computers if you can help, thanks in advance Have you considered MAKING this into one file? You could call your list and then USE a nested for loop to run the functions of the timer.bat file.
For instance:
@echo off FOR /f %%u IN (list.txt) DO (
FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Second /Format:table ^| findstr /r "."') DO ( set Milisecond=%time:~9,2% set Day=%%A set Hour=%%B set Minute=%%C set Second=%%D ) set /a Start=%Day%*8640000+%Hour%*360000+%Minute%*6000+%Second%*100+%Milisecond% copy c:\temp\1meg.test \\%%u\c$\temp
FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Second /Format:table ^| findstr /r "."') DO ( set Day=%%A set Hour=%%B set Minute=%%C set Second=%%D ) set Milisecond=%time:~9,2% set /a End=%Day%*8640000+%Hour%*360000+%Minute%*6000+%Second%*100+%Milisecond% set /a Diff=%End%-%Start% set /a DiffMS=%Diff%%%100 set /a Diff=(%Diff%-%DiffMS%)/100 set /a DiffSec=%Diff%%%60 set /a Diff=(%Diff%-%Diff%%%60)/60 set /a DiffMin=%Diff%%%60 set /a Diff=(%Diff%-%Diff%%%60)/60 set /a DiffHrs=%Diff% :: format with leading zeroes if %DiffMS% LSS 10 set DiffMS=0%DiffMS!% if %DiffSec% LSS 10 set DiffMS=0%DiffSec% if %DiffMin% LSS 10 set DiffMS=0%DiffMin% if %DiffHrs% LSS 10 set DiffMS=0%DiffHrs% echo %%u %DiffHrs%:%DiffMin%:%DiffSec%.%DiffMS% >> c:\temp\timer.txt )
|