Solved

MS Dos batch file log and append to file

Posted on 2013-06-06
5
655 Views
Last Modified: 2013-06-07
I have a batch file that runs fine.

How can I run this with logging to file on the second command only?

This works fine when I run it
I just want to log results of the executeable to a txt file

@echo off
cd "c:\program files (x86)\Java\jre7\bin"

java -cp m5.jar;m5-data-objects.jar;webservices-rt.jar;log4j-1.2.13.jar org.m5.sdk.hostedconnect.v2.MonitorMultipleExample
0
Comment
Question by:lrbrister
  • 2
  • 2
5 Comments
 
LVL 9

Assisted Solution

by:Misbah
Misbah earned 250 total points
ID: 39227302
add this to the end of your command line :  > log.txt

java -cp m5.jar;m5-data-objects.jar;webservices-rt.jar;log4j-1.2.13.jar org.m5.sdk.hostedconnect.v2.MonitorMultipleExample > log.txt
0
 
LVL 82

Accepted Solution

by:
oBdA earned 250 total points
ID: 39227306
You just redirect the output with ">SomeFile" (will erase an existing file before writing) or ">>SomeFile" (will add to an existing file):
@echo off
cd "c:\program files (x86)\Java\jre7\bin"

java -cp m5.jar;m5-data-objects.jar;webservices-rt.jar;log4j-1.2.13.jar org.m5.sdk.hostedconnect.v2.MonitorMultipleExample >"C:\The\file.log" 2>&1

Open in new window

The "2>&1" redirects stdout (where most program write their error output) to the file, too.
0
 

Author Closing Comment

by:lrbrister
ID: 39228703
Thanks guys.
Watch for follow-up
0
 
LVL 82

Expert Comment

by:oBdA
ID: 39228727
Just noticed an error: the last line in my previous post should of course have been 'The "2>&1" redirects stderr (where most program write their error output) to the file, too."
0
 

Author Comment

by:lrbrister
ID: 39229011
oBdA
I saw that and modified it.  No worries
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
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…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

707 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

19 Experts available now in Live!

Get 1:1 Help Now