Click to See Complete Forum and Search --> : Process.Start, write to file


clb2196
June 29th, 2009, 12:02 PM
Author: Carissa

I am trying to use Process.Start to run a command that opens SQLPlus, runs a query, and puts the output in a file. (There are reasons I can't use a batch file).


Right now it works, except the results are written in the new command window it opens to run sqlplus. So I've been trying to write the results to a file, or for now at least to the console.

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = db_startsql;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.Arguments = info;
p.Start();
Console.WriteLine("done with start");
p.WaitForExit();
Console.WriteLine("Done waiting for exit");
string output = p.StandardOutput.ReadToEnd();
Console.Write(output);

It gets to "done with start", and then hangs.

If I output db_startsql+info, and put that in a command line it works, so that's not the problem. Help?

BigEd781
June 29th, 2009, 01:20 PM
Well, it looks like your external app is not exiting. It's hard to help without seeing the code behind that program.

Arjay
June 29th, 2009, 03:29 PM
Please show what are contained within the db_startsql and info variables.