|
Answer» I'm having a problem outputing the screen results of a batch file (I.E. results of a timed run of an NBTSTAT or other SYSTEM query ) as a text file to be SENT to a directory such as c:\10\Status. Any suggestions appreciated..I would think you need to redirect the output:
nbtstat -n > c:\10\Status
Use any of the nbtstat switches you need.
Hope this helps. Thank you for the redirect suggestion. It will works in the limited example I sent. The problem is I need the complete contents of the screen to display, both on-screen and in a text file. I should have previously stated the extent of the batch file executions - please refer to the example code below. I need the dates and contents of the tracerts and pings and just to foul things further, there is also a 30 second delay between one of the executions.
@ECHO OFF Date /T Time /T ECHO tracert msn.com tracert mail.mail.com ECHO. ECHO. ECHO OFF PING 1.1.1.1 -n 10 -w 3000 >NUL ECHO. Date /T Time /T ECHO ping msn.com PAUSE Are your text files intended for a permanent record or just a temporary thing until the next time the batch file is run?Just redirect the output from the entire batch run to a file. You can't send a data stream to two separate devices (console and a file) at the same time. A workaround would be to TYPE the file with the redirected output.
ie. batchfile > batch.txt
A few potential problems. The redirect of the PING to the nul device will produce no output and override the redirect of the batch file output. The PAUSE will produce a "Press any key to continue . . ." message to the output file but the user will never see it; makes responding to the message difficult.
Note: the time delay in the PING command will not change any results. Just delay the inevitable.
Hope this helps. The redirect of the PING to the nul device will produce no output and override the redirect of the batch file output.
Not so. Pinging to a non-existant IP and redirecting to the nul device simply acts as a timer and introduces a delay.I stand corrected 2K. I should have worded it a bit BETTER. Sometimes my BRAIN works on a 30 second delay. <<2k dummy wrote: Are your text files intended for a permanent record or just a temporary thing until the next time the batch file is run?>> Thanks for insights 2k (caught that nul ping thing, huh) - the text files are intended for temporary record only.
Sidewinder: Thanks for all inputs. Your suggestion to redirect the entire batchfile to a text file will work out OK for the actual application. Originally I had a desire to view the batch file output on the console as well as generate a temporary text file record, but that complication both elludes me and is probably unnecessary.As Sidewinder said, you can use the type command to do it.
ping msn.com > c:\10\status\msnping.txt type c:\10\status\msnping.txt
do the same with other ping command. You can add lines to delete them before the batch EXITS. Or if you want to save them for later review, you can add lines at the beginning of the batch to delete before creating new text files.
|