Sunday, December 31, 2017
How to Run in Cgywin from C
How to Run in Cgywin from C
Use the following code:
public string runCygwin()
{
using (Process p = new Process())
{
/*Use the bash shell in cygwin folder*/
ProcessStartInfo info = new ProcessStartInfo(@"D:cygwin64 in ash");
/*Put the command to be run in test.bsh*/
info.Arguments = @"--login ""/cygdrive/D/C_Drive/Desktop/z3-str/tests.bsh""";
/**Side Info:Content in test.bsh file**/
string bshContent =
"/cygdrive/D/C_Drive/Desktop/z3-str/Z3-str.py -f " +
"/cygdrive/D/C_Drive/Desktop/z3-str/tests/Concat001";
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
p.StartInfo = info;
p.Start();
string output = p.StandardOutput.ReadToEnd();
// process output
return output;
}
}