Solved

How to log execution of batch file to text file?

Posted on 2003-11-11
3
2,658 Views
Last Modified: 2008-10-14
I have a batch file that executes various DOS commands and external
applications (e.g. SCP secure copy program). The batch file is executed on a
schedule by Windows 2000 Scheduled Tasks. I need to capture the output (that
I would see on the screen  if I ran the batch file manually in a Command
Prompt) in a text file for troubleshooting purposes.

Here is a sample from the batch file:

CreateWWWSchedule.Exe
SCP -q -pw XXXX sched_denmark.html xxx@xxx.xxx.com:/xxx/xxx/.
net use n: /d
net use n: \\xxx\wwwroot
copy sched_france.html n:\fr

Thanks
0
Comment
Question by:lneville
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
brianadkins earned 125 total points
ID: 9721932

In your scheduled task, you could just change the command line and append ">> path\logfile.txt"

If you do this, you may want to add a few new lines to your batch file such as:

echo.
echo.
echo.
echo ===================================
echo.
echo Script %0 Run on %DATE%  %TIME%
echo.
echo ===================================
echo.
:: then the rest of your batch file


This way, you can easily scan through the log file for specific runs

-Brian Adkins
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9721940
Did you already try to schedule something like

cmd /c batch.cmd >>batch.log

You may need to give fullpaths :

cmd /c x:\batch.cmd >>x:\batch.log
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9721952
hmmm, not fast enough it seems. Sorry brian :)
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Script to copy every 7th file 10 60
Remote Application Install 5 75
DOS Database Program in Windows 10 5 124
How can I save all open docs into a given folder 12 120
One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question