472,368 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,368 software developers and data experts.

How to execute a python script in .NET application

Hi,

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

Regards,
Chandra

Oct 6 '06 #1
5 7046
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
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

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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: spec | last post by:
Hi all, I know nothing about Python. What I need to do is to get a Python script to execute a local shell script. I do not need any output. What would be th eeasiest way to accomplish this? ...
1
by: Vertilka | last post by:
What i need from my C application to do ? 1) To execute a python script from file. 2) The python script will call functions in my C application. According to the answer from Ravi Teja (topic "C...
17
by: somialis | last post by:
I have a test environment in python. it is executed by the following command on the command prompt. 1) First i have to go to the dir where the .py file is 2) then i simply execute python...
5
by: johnny | last post by:
Anyone know how I can make Machine A python script execute a python script on Machine B ?
4
by: brad | last post by:
When I use idle or a shell to execute a python script, the script executes in the directory it is currently in (in this case, my desktop). However, when using GNOME and right clicking the py script...
3
by: joe jacob | last post by:
I configured apache to execute python scripts using mod_python handler. I followed below mentioned steps to configure apache. 1. In http.conf I added <Directory...
1
by: suman lal banik | last post by:
Hello, My self suman L.B. I want one help. I want to execute one python script from .Net application using c#. Can any one help me in this regard.Please explain in detail. ...
0
by: David | last post by:
- Are there any peculiarities with using curs.executemany(...) vs. multiple How many times are you calling execute vs a single executemany? The python call overhead will add up for thousands of...
0
by: srinivasan srinivas | last post by:
This is ok. Is there any other way to find it out? Thanks, Srini ----- Original Message ---- From: Gerhard Häring <gh@ghaering.de> To: python-list@python.org Sent: Friday, 20 June, 2008...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.