473,654 Members | 3,040 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to execute a python script in .NET application

Hi,

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

Regards,
Chandra

Oct 6 '06 #1
5 7456
hg
Chandra wrote:
Hi,

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

Regards,
Chandra
py**********@py thon.org ?
Oct 7 '06 #2
Chandra wrote:
Hi,

Is there a way to execute a python script(file) in ASP.NET application
(programmatical ly)??
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
(programmatical ly)??

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.Diagnost ics

public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Labe l Label1;

private void Page_Load(objec t sender, System.EventArg s e)
{
ProcessStartInf o startInfo;
Process process;
string directory = @"c:\python\pyt hon24\Lib\site-packages";
string script = "test.py";

startInfo = new ProcessStartInf o("python");
startInfo.Worki ngDirectory = directory;
startInfo.Argum ents = script;
startInfo.UseSh ellExecute = false;
startInfo.Creat eNoWindow = true;
startInfo.Redir ectStandardOutp ut = true;
startInfo.Redir ectStandardErro r = true;

process = new Process();
process.StartIn fo = startInfo;
process.Start() ;

string s;
while ((s = process.Standar dOutput.ReadLin e()) != 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
(programmatical ly)??

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.Diagnost ics

public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Labe l Label1;

private void Page_Load(objec t sender, System.EventArg s e)
{
ProcessStartInf o startInfo;
Process process;
string directory = @"c:\python\pyt hon24\Lib\site-packages";
string script = "test.py";

startInfo = new ProcessStartInf o("python");
startInfo.Worki ngDirectory = directory;
startInfo.Argum ents = script;
startInfo.UseSh ellExecute = false;
startInfo.Creat eNoWindow = true;
startInfo.Redir ectStandardOutp ut = true;
startInfo.Redir ectStandardErro r = true;

process = new Process();
process.StartIn fo = startInfo;
process.Start() ;

string s;
while ((s = process.Standar dOutput.ReadLin e()) != 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
2980
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? Thanks!
1
1782
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 app and Python"), I need to extend embedded python in my C application. I saw several functions: PyRun_AnyFileExFlags, PyRun_SimpleFileExFlags, PyRun_FileExFlags.
17
176697
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 filename.py and the GUI appears Now i have to create a script which could open the GUI...i.e execute the command "python filename.py" from inside itself.. I tried the "system" command inside my script but the GUI did not appear.i.e i tried system("python...
5
4408
by: johnny | last post by:
Anyone know how I can make Machine A python script execute a python script on Machine B ?
4
2349
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 and selecting 'open with python', the execution occurs in my home directory, not my desktop. Is there a way to force py scripts to always run within the directory that they reside in? Thanks
3
4932
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 "D:/softwares/Apache2.2/htdocs"> AddHandler mod_python .py PythonHandler mptest PythonDebug On </Directory>
1
1635
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. Thanking you, Regards, Sman Lal Banik
0
4048
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 calls. The relevant source code is here if you're interested: http://svn.python.org/projects/python/trunk/Modules/_sqlite/cursor.c
0
2046
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 10:03:30 PM Subject: Re: Execute a script on a remote machine
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.