help me with this batch file

ok guys here what i want to do
i want to output time alongwith ping into a text file ..
like this

time ping'd google.co.in
time ping'd google.co.in

i have written the batch file like this

@ECHO OFF

:LOOPSTART

time /t >> experi.txt
ping Google -n 1 >> experi.txt

GOTO LOOPSTART

but i get results like this

07:37 PM

Pinging Google [74.125.235.51] with 32 bytes of data:
Reply from 74.125.235.51: bytes=32 time=340ms TTL=50

Ping statistics for 74.125.235.51:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 340ms, Maximum = 340ms, Average = 340ms
07:37 PM

Pinging Google [74.125.235.51] with 32 bytes of data:
Reply from 74.125.235.51: bytes=32 time=340ms TTL=50

Ping statistics for 74.125.235.51:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 340ms, Maximum = 340ms, Average = 340ms
07:37 PM

i want to remove that ping statistics line alongwith its bottom four line and want only the

time ping
time ping
EDIT
----------------------------------------------------------------------------------------------

like this output example
8:09 PM Reply from 74.125.235.51: bytes=32 time=390ms TTL=50
8:10 PM Reply from 74.125.235.51: bytes=32 time=385ms TTL=50
8:11 PM Reply from 74.125.235.51: bytes=32 time=388ms TTL=50
8:12 PM Reply from 74.125.235.51: bytes=32 time=387ms TTL=50

thing , what to correct in the batch code ??
 
change the -n 1 part to -t

Then u will get summary after ever minute not after every ping...

This is all I know, i think wait for other gurus to post here...
 
I think I don't get what you are looking for. What you posted looks very simplistic. Don't you want to check the result of the ping? If not, just do something like this:

Code:
time /t >> experi.txt
ping [url]www.google.com[/url] -n 1
echo ping'd [url]www.google.com[/url] >> experi.txt
 
agantuk said:
I think I don't get what you are looking for. What you posted looks very simplistic. Don't you want to check the result of the ping? If not, just do something like this:

Code:
time /t >> experi.txt
ping [url]www.google.com[/url] -n 1
echo ping'd [url]www.google.com[/url] >> experi.txt

i want the output to be like this

8:09 PM Reply from 74.125.235.51: bytes=32 time=390ms TTL=50
8:10 PM Reply from 74.125.235.51: bytes=32 time=385ms TTL=50
8:11 PM Reply from 74.125.235.51: bytes=32 time=388ms TTL=50
8:12 PM Reply from 74.125.235.51: bytes=32 time=387ms TTL=50
 
agantuk said:
Try this:

Code:
time /t >> myfile.txt
ping [url]www.google.com[/url] -n 1 | find "Reply from" >> myfile.txt
thanks a lot for this pipelining the thing ....ok i get output as
09:02 PM
Reply from 74.125.235.49: bytes=32 time=340ms TTL=50
09:02 PM
Reply from 74.125.235.49: bytes=32 time=339ms TTL=50
09:02 PM
Reply from 74.125.235.49: bytes=32 time=339ms TTL=50
09:02 PM
Reply from 74.125.235.49: bytes=32 time=339ms TTL=50
09:02 PM

how do i make the time and the ping in one line ?? also how do i include seconds ?? its showing only hour:minute but not second ..

EDIT

well i was able to show seconds using this

@ECHO OFF

:LOOPSTART

timeout 1
echo %time% >> bsnlpingtime.txt
ping 192.168.1.1 -n 1 | find "Reply from" >> bsnlpingtime.txt

GOTO LOOPSTART

still both are in different lines , how to make them in one line ??
but finally my motto has not been served , i wanted even the error messages to get logged , but since we are using find command it will only log "reply from" what about logging "request timed out "

i am thinking of string extraction thing instead of find so that whatever will be the first line that will be copied to file and not only the "reply from" thing ..

but what command will do that ??
 
Use the one below to remove the spaces. I won't make any more changes since you seem to be too lazy to Google. Reason: I have zero clue about batch scripts, but I still came up with the below just by Googling.

Code:
for /f "delims=;" %%p in ('ping [url]www.google.com[/url] -n 1 ^| find "Reply from"') do @echo %mytime% %%p >> myjunk.txt
 
agantuk said:
Use the one below to remove the spaces. I won't make any more changes since you seem to be too lazy to Google. Reason: I have zero clue about batch scripts, but I still came up with the below just by Googling.

Code:
for /f "delims=;" %%p in ('ping [url]www.google.com[/url] -n 1 ^| find "Reply from"') do @echo %mytime% %%p >> myjunk.txt
but finally my motto has not been served , i wanted even the error messages to get logged , but since we are using find command it will only log "reply from" what about logging "request timed out "

i am thinking of string extraction thing instead of find so that whatever will be the first line that will be copied to file and not only the "reply from" thing ..

but what command will do that ??
 
Back
Top