Connecting Tech Pros Worldwide Help | Site Map

execute perl CGI from PHP

  #1  
Old July 16th, 2005, 11:48 PM
w i l l
Guest
 
Posts: n/a
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

  #2  
Old July 16th, 2005, 11:49 PM
Luke Ross
Guest
 
Posts: n/a

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

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
perl extension for PHP - stuck? billb answers 4 May 30th, 2007 03:15 PM
Perl vs PHP? Keith answers 4 July 17th, 2005 02:48 PM
Making a .php page a .cgi page Andrew DeFaria answers 9 July 17th, 2005 01:37 PM
Using PHP to compile uploaded sourcecode with cygwins gcc? DvDmanDT answers 4 July 17th, 2005 01:09 AM