execute perl CGI from PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • w i l l

    #1

    execute perl CGI from PHP

    I am trying to execute a perl CGI from within a PHP script. I have
    tried the following notation without success.

    <?php include("http://" . $_SERVER['SERVER_NAME'] .
    "/somedir/afile.cgi"); ?>

    The CGI works on it's own without problems. Is this a limitation of
    PHP?

    Thanks,
    w i l l

  • Luke Ross

    #2
    Re: execute perl CGI from PHP

    Hi,

    w i l l wrote:[color=blue]
    > I am trying to execute a perl CGI from within a PHP script. I have
    > tried the following notation without success.
    >
    > <?php include("http://" . $_SERVER['SERVER_NAME'] .
    > "/somedir/afile.cgi"); ?>
    >
    > The CGI works on it's own without problems. Is this a limitation of
    > PHP?[/color]

    include() brings in another PHP file rather than requesting another page.

    Under Apache you can use virtual("/somedir/afile.cgi"); to execute a
    subrequest.

    If you're not using Apache, but have URL wrapper turned on, you can use:
    $fd = fopen("http://" . $_SERVER['SERVER_NAME'] . "/somedir/afile.cgi",
    "r");
    fpassthru($fd);

    Or as someone else has suggested, you could run it directly using the
    system execution functions if the script is on the same machine.

    Regards,

    Luke

    Comment

    Working...