Redirect text file changes to batch file output - windows

I am using a build tool which only writes its output to a text file, and I would like to use that build tool on a build server. The tool is Atmel Studio, and I try to start a build this way.
While the build is running, it writes its result to a text file, then the process of the tool ends.
I would like to have the text file output written to stdout, i.e. I would like the same effect as if the tool would write to the commandline output instead of the text file, in order to see what is going on during the build.
Is there any kind of command on a batch file to achieve this? If not, is there a good alternative?

Related

Execute command with windows command line and capture output in rolling file

I have a command line program that produces output that I would like to log to a file.
I know that I can redirect the output of a command (foo.exe for example) to a file using the > operator, but for this current project I need more than just simple output functionality. I would also mention that I can't change any of the code in foo.exe.
I am looking for a command line utility/command that can do the following:
Log the output of a foo.exe to a file
Place a timestamp on each individual output of foo.exe
When the current log file reaches a certain specified size (say 1mb), close the current file and start putting log data in a new file.
In a perfect world the utility would encapsulate the command I wish to execute and log its output, looking something like the following:
log.exe -MaxLogSize=1mb -FileName="FooOutput.log" -Execute="foo.exe"
Any help or suggestions are appreciated!

Read a Xcode Instruments .trace file generated from Automation.tracetemplate

I need to read/parse instruments trace file generated using Automation.tracetemplate. Is there any command line utility or anything that can read the file without opening instruments.
I am running an automation script on an iOS application using instrument command from the command line which generates aan instruments trace file as an output result. Now i need to read/parse this file without opening instruments so that i can have a readable data to use.
In the case of the UIAutomation trace file, parsing the data is very simple. Instead of looking at the "1.run" file generated inside the Instruments.trace file; look inside the "Automation Results.plist" file. That's just XML so you can easily write a parser for it.

How to make MSBuild print output from a custom tool?

I have a project, which use a .rules file to build some non-c++ sources. How to make MSBuild print diagnostic output from this tool? -- Precisely cerr stream.
(I silently presume, the M$ team have not reached that level of insanity, to give the custom building tools functionality without possibility to print errors from them.)
I've actually noticed you marked question with label visual-studio-2008. I guess it means your custom build tool processes non cpp files in vc2008 project? If so, I think it is not built by msbuild but with vcbuild.
In this case try to add echo on in front of command executed by custom tool.
Vcbuild creates batch files in %temp% that first line contains #echo off and then it is executed. So if you add echo on you should see complete output in output window including command line used for command execution.

How do I Pipe Standard Error to a File in DOS (Batch File)?

How do I pipe standard error to a file in a DOS batch file? Piping using >> only pipes the standard output and the standard error still goes to the console.
Details of my issue:
I am running WinRAR via command line, in an automated daily backup. And the following example pipes WinRar's output, but not the error output which is what I want most, to winraroutput.txt:
RAR.exe a -esh -r "E:\backup.rar" "D:\*.*" >> winraroutput.txt
The issue is sometimes files are in use and when they are I want to know they were missed in the archive and record this in a .txt file next to each .rar file in case we ever have to go back. The missing files are easily replaced by reinstalling programs so it's no big deal to replace them, as long as we know they are missing. So it's just information that would be great to know, not necessary, in the time of need.
How do I output just the standard error output to the .txt file and, if possible but not necessary, leave the the regular output to the console?
Bonus points:
Bonus points if you can tell me how to delete the file if it's blank (no errors)! Asked here: How do I Detect (and Delete) a File if it is Empty using a Windows Batch File?.
Try this:
command.exe 2>file.txt
Or if you prefer not to see any errors, send it to nul:
command.exe 2>nul
This should leave std::cout on the console.

command line tool text output

I have a small command line tool and after running it, I'd like to display the text output in a way that's easy for someone to copy/paste and save it or email it to someone else.
Copy/pasting from a command prompt is not done in the standard way, so I don't want people to have to copy/paste from there. Saving the file to disk is possible, but the folder where the tool is located may not have access rights so the user would have to configure the output file location (this may be too tricky for some users).
I was thinking of launching notepad with some text in it, generated from the command line tool. Is this possible? Any other suggestions?
You can use clip.
After you have clip, which can be downloaded from the link above, you use the pipe (|) command to copy the previously executed command's output to the clipboard.
The article gives you the full explanation, but here are the basics with examples:
dir /h | clip – Copy the help manual for DIR command to the clipboard
tracert www.labnol.org | clip – Trace the path from your computer to another website – the output is automatically copied to the clipboard and not displayed on the screen.
netstat | clip - Check if your computer is connecting to websites without your knowledge.
I think your command sould receive the destination e-mail as a parameter and then after executing, your command you can have simple script/.BAT file which e-mails your text output to the user using the standard Telnet SMTP commands, like explained for example in the following page:
"http://www.yuki-onna.co.uk/email/smtp.html".
You could add an option to your program that tells it to copy its own output to the clipboard using the clipboard API. Then the user could just paste it.
I like the clip suggestion, though.

Resources