starting some Python script from C#
Gerard Flanagan
grflanagan at yahoo.co.uk
Sat May 27 07:22:20 EDT 2006
tatamata wrote:
> Hello.
>
> How can I run some Python script within C# program?
>
---------------------------------------------------------------------------------
ProcessStartInfo startInfo;
Process process;
string directory;
string pyArgs;
string script;
startInfo = new ProcessStartInfo("python");
startInfo.WorkingDirectory = directory;
startInfo.Arguments = script + " " + pyArgs;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
process = new Process();
process.StartInfo = startInfo;
process.Start();
string s;
while ((s = process.StandardOutput.ReadLine()) != null)
{
//do something with s
}
---------------------------------------------------------------------------------
HTH
Gerard
More information about the Python-list
mailing list