Solved

How to log execution of batch file to text file?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

24 Experts available now in Live!

Get 1:1 Help Now