By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,550 Members | 1,161 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,550 IT Pros & Developers. It's quick & easy.

How to execute a python script in .NET application

P: n/a
Hi,

Is there a way to execute a python script(file) in ASP.NET application
(programmatically)??

Regards,
Chandra

Oct 6 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
hg
Chandra wrote:
Hi,

Is there a way to execute a python script(file) in ASP.NET application
(programmatically)??

Regards,
Chandra
py**********@python.org ?
Oct 7 '06 #2

P: n/a
Chandra wrote:
Hi,

Is there a way to execute a python script(file) in ASP.NET application
(programmatically)??
Probably use IronPython, I should think.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Oct 7 '06 #3

P: n/a

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;
}
}
}

Oct 7 '06 #4

P: n/a
MC
Hi!

dotNET can use (call) COM-servers

In pywin, there are exemple of COM-server, in Python, who can run
(on-the-fly) Python code.

This give a way for run Python's scripts from dotNET, Excel, Word,
Internet-Explorer (HTA), C#, etc. I have try all these things, with
success.

--
@-salutations

Michel Claveau
Oct 7 '06 #5

P: n/a
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;
}
}
}
Oct 9 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.