Solved

How to log execution of batch file to text file?

Posted on 2003-11-11
3
2,633 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now