Solved

How to log execution of batch file to text file?

Posted on 2003-11-11
3
2,670 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

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…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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