W
Wensi Peng
Hello,
I want to add sequence number, 1, 2,3, .... in my output file to
identify/sort results by the number.
How can I do it in the batch files below? And how can I assign a line read
from screen after |findstr to a variable, so I
can use the value for the next command?
Thanks
Wensi
I want output like:
1, server1, reply
2, server2, reply
....
no, servern, reply.
Here are my tries:
My example 1: ( problem: how can I add the number)
for /f "tokens=1* delims=" %%i in (servers.txt) do (
echo %%i, >> output.txt
ping -n 1 %%i |findstr /i "reply from timed out unknown" >> output.txt
)
My example 2: (problem: how can I get the number and assign the value to a
variable)
set intNum = 0
for /f "tokens=1* delims=" %%i in (servers.txt) do (
echo intNum, %%i
ping -n 1 %%i |findstr /i "reply from timed out unknown"
set intNum = %intNum& +1
)
I want to add sequence number, 1, 2,3, .... in my output file to
identify/sort results by the number.
How can I do it in the batch files below? And how can I assign a line read
from screen after |findstr to a variable, so I
can use the value for the next command?
Thanks
Wensi
I want output like:
1, server1, reply
2, server2, reply
....
no, servern, reply.
Here are my tries:
My example 1: ( problem: how can I add the number)
for /f "tokens=1* delims=" %%i in (servers.txt) do (
echo %%i, >> output.txt
ping -n 1 %%i |findstr /i "reply from timed out unknown" >> output.txt
)
My example 2: (problem: how can I get the number and assign the value to a
variable)
set intNum = 0
for /f "tokens=1* delims=" %%i in (servers.txt) do (
echo intNum, %%i
ping -n 1 %%i |findstr /i "reply from timed out unknown"
set intNum = %intNum& +1
)