Solved

MS Dos batch file log and append to file

Posted on 2013-06-06
5
680 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 83

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 83

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What the difference between blend and Visual Studio 3 99
How do I delete 2 44
windbg taking it's time 32 90
Why is "packages element is not declared"? 2 212
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
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…

775 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