[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

MS Dos batch file log and append to file

Posted on 2013-06-06
5
Medium Priority
?
712 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 1000 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 1000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
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…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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…

649 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