Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I capture command-line text that is not sent to stdout?

Tags:

c#

windows

cmd

lame

I am using the LAME command line mp3 encoder in a project. I want to be able to see what version someone is using. if I just execute LAME.exe with no paramaters i get, for example:

C:\LAME>LAME.exe
LAME 32-bits version 3.98.2 (http://www.mp3dev.org/)

usage: blah blah
blah blah

C:\LAME>

if i try redirecting the output to a text file using > to a text file the text file is empty. Where is this text accessable from when running it using System.Process in c#?

like image 731
Dave Avatar asked Feb 05 '10 17:02

Dave


1 Answers

It may be output to stderr instead of stdout. You can redirect stderr by doing:

LAME.exe 2> textfile.txt

If this shows you information, then LAME is outputting to the standard error stream. If you write a wrapper in C#, you can redirect the standard error and output streams from ProcessStartInfo.

like image 122
Reed Copsey Avatar answered Oct 06 '22 00:10

Reed Copsey