Connecting Tech Pros Worldwide Forums | Help | Site Map

execute perl CGI from PHP

w i l l
Guest
 
Posts: n/a
#1: Jul 16 '05
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
Guest
 
Posts: n/a
#2: Jul 16 '05

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