Solved

MS Dos batch file log and append to file

Posted on 2013-06-06
5
702 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
[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
  • 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 85

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 85

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

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…
The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
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…

688 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