starting some Python script from C#

tatamata zlatko.matic1 at sb.t-com.hr
Sat May 27 10:15:05 EDT 2006


thanks.

"Gerard Flanagan" <grflanagan at yahoo.co.uk> je napisao u poruci interesnoj 
grupi:1148728940.440692.166330 at i39g2000cwa.googlegroups.com...
> 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