How to execute a python script in .NET application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chandra

    #1

    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

  • hg

    #2
    Re: How to execute a python script in .NET application

    Chandra wrote:
    Hi,
    >
    Is there a way to execute a python script(file) in ASP.NET application
    (programmatical ly)??
    >
    Regards,
    Chandra
    >
    pythondotnet@py thon.org ?

    Comment

    • Steve Holden

      #3
      Re: How to execute a python script in .NET application

      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

      Comment

      • Gerard Flanagan

        #4
        Re: How to execute a python script in .NET application


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

        Comment

        • MC

          #5
          Re: How to execute a python script in .NET application

          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


          Comment

          • Chandra

            #6
            Re: How to execute a python script in .NET application

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

            Comment

            Working...