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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command-Line Process in WebMethod returns null?

Status
Not open for further replies.

stormbind

Technical User
Mar 6, 2003
1,165
GB
Hi all,

Could you please identify below why the output from grep is not being returned in the SOAP response?

Many thanks,

Code:
[WebMethod]
public string Grep()
{
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = @"C:\mingw\bin\grep.exe";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
return output;
}

--Glen :)
 
Resolved it like this, where grep is the exe+args.

Code:
p.StartInfo.FileName = "cmd";
p.StartInfo.Arguments = "/C \"" + grep + "\"";

--Glen :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top