Best way to run a perl script from php on windows?

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

    #1

    Best way to run a perl script from php on windows?

    Hi. I have a perl script that can be run at the command line to take some
    HTML and do something filtering with it.

    What I want to do is use it from within PHP (run the script on a var, eg:
    echo fancyHtmlFilter ($inputHtml); ).

    I've thought about accessing the perl script via HTTP, but then I would have
    to modify the perl script to accept data from HTTP forms, which I have no
    idea how to do.

    I've played around quite a bit with PHP prog exec functions, but having
    problems getting an output, or getting it to run the script full-stop most
    of the time, and have no idea how I'm supposed to pass the HTML/data to it.

    I'm running windows BTW, so that's probably half the problem.

    Does anyone know what the best way to approach this is? Any good tutorials
    specificly for passing/outputting data from command-line run perl scripts?
    Can't seem to find anything.


    Thanks, Justin.


  • Jeffrey Silverman

    #2
    Re: Best way to run a perl script from php on windows?

    On Tue, 23 Mar 2004 19:57:06 +1200, Justin wrote:
    [color=blue]
    > Does anyone know what the best way to approach this is? Any good tutorials
    > specificly for passing/outputting data from command-line run perl scripts?
    > Can't seem to find anything.[/color]

    How much searching did you do?

    Anyways, here are some pointers:
    Execute an external program and display raw output

    Execute an external program and display the output





    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


    later...
    --
    Jeffrey D. Silverman | jeffrey AT jhu DOT edu
    Website | http://www.wse.jhu.edu/newtnotes/

    Comment

    • Chung Leong

      #3
      Re: Best way to run a perl script from php on windows?


      Uzytkownik "Justin" <usernet@soupis goodfood.networ k> napisal w wiadomosci
      news:GVR7c.3011 $u%1.431646@new s02.tsnz.net...[color=blue]
      > I've played around quite a bit with PHP prog exec functions, but having
      > problems getting an output, or getting it to run the script full-stop most
      > of the time, and have no idea how I'm supposed to pass the HTML/data to[/color]
      it.[color=blue]
      >
      > I'm running windows BTW, so that's probably half the problem.
      >
      > Does anyone know what the best way to approach this is? Any good tutorials
      > specificly for passing/outputting data from command-line run perl scripts?
      > Can't seem to find anything.[/color]

      Presumably the PERL script grabs the HTML from stdin. It'd be pretty hard
      for PHP to communicate directly with the PERL process, as the PHP API
      haven't include low level interprocess functions. With a bi-directional pipe
      you run the risk of the two deadlocking. The more reliable--though not very
      elegant--solution is to write the HTML into a temp file, pipe it into the
      PERL script, and capture the output:

      $tempfile = tempnam();
      file_puts_conte nts($tempfile, $html);
      $output = `perl < "$tempfile" `;


      Comment

      Working...