Forum Home
Press F1
 
Thread ID: 51823 2004-11-30 21:24:00 Batch File Help Kodaz (6489) Press F1
Post ID Timestamp Content User
298317 2004-11-30 21:24:00 Hi,

I have been asked by my boss to create a batch file that pings an IP address every minute and exports the "reply..." line to a text file with the date and time above each four ping results.

I am able to make a batch file that will ping an address but am not sure how to export it to a file with the date and time in it and with only the "reply..." lines.

Can anyone help?
Kodaz (6489)
298318 2004-11-30 23:49:00 ping www.google.com >> ping.txt

'>>" means append output from command to file ping.txt
tested on xp pro
beama (111)
298319 2004-11-30 23:53:00 for got to say ">>" will also create the file ping.txt on first use after that will append (add to) to that file
">" will also create on first use but not append but will overwrite each time used
beama (111)
298320 2004-11-30 23:54:00 The redirection operators are what you want.

">" writes the output of a command to a file (creating the file, or overwriting the file if it exists already).

">>" appends the output of a command to a file (creating the file if it doesn't exist, but adds to the end if it does exist).

date >> logfile.txt might work for the date ... I haven't done this so it might want a response :-(... I have an idea that XP has an environment variable which automatically has the date so something like
echo $DATE >> logfile.txt would do it "properly".
ping some.site.org >> logfile.txt handles the ping outputs.
Graham L (2)
298321 2004-12-01 00:01:00 snap Graham beama (111)
298322 2004-12-01 00:07:00 Umm ... I'm too *nix oriented. bash uses "$" to expand EVs, DOS uses "%". ;-)

echo %DATE% >> logfile.txt will do the date for you. Look at the help for environment variables. It seems you get the date in your current screen date format.
Graham L (2)
1