Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirecting Shell stdout to c # program

Status
Not open for further replies.

newbkd

Programmer
Jan 7, 2003
1
US
Hello all. I am a newbie for c #. I am trying to write a windows application in c # that will invoke a perl script with some arguments and I want the output of the perl script to be displayed onto a label of a c # form. I am using System.Diagnostics.Process class to achive this. Now for me to redirect the stdout, this class requires me to turnoff shell execute (Process.StartInfo.UseShellExecute=false;). If I do this it gives me error saying not a win32 application which I undestand its not. If I don't set it to false it can't do the redirection. Is there any other way to achive this?
Any help is greatly appreciated.
Thanks,

Kedar

Here is the code snipplet I am using.



this.output.Text="Running the process....";
Process perlproc = new Process();

perlproc.StartInfo.WorkingDirectory=@"C:\Documents and Settings\Owner\My Documents";
perlproc.StartInfo.FileName=@"hello.pl";
perlproc.StartInfo.CreateNoWindow=true;
perlproc.EnableRaisingEvents=true;
perlproc.Exited +=new System.EventHandler (this.Process_Exited);
perlproc.StartInfo.UseShellExecute=false;
perlproc.StartInfo.RedirectStandardOutput=true;




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top