Thanks all of them, i used the command line process (executing the
script in cmd shell) method for executing python script.

Regards,
Chandra

Gerard Flanagan wrote:
> Chandra wrote:
>
> > Hi,
> >
> > Is there a way to execute a python script(file) in ASP.NET application
> > (programmatically)??
> >
> > Regards,
> > Chandra
>
>
> I thought IIS would prevent this, but the following works for me at
> home (ASP.NET 1.1). A production setup may be a different matter.
>
> using System.Diagnostics
>
>       public class WebForm1 : System.Web.UI.Page
>       {
>               protected System.Web.UI.WebControls.Label Label1;
>
>               private void Page_Load(object sender, System.EventArgs e)
>               {
>                       ProcessStartInfo startInfo;
>                       Process process;
>                       string directory = 
> @"c:\python\python24\Lib\site-packages";
>                       string script = "test.py";
>
>                       startInfo = new ProcessStartInfo("python");
>                       startInfo.WorkingDirectory = directory;
>                       startInfo.Arguments = script;
>                       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)
>                       {
>                               Label1.Text += s;
>                       } 
>               }
> }

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to