Including a CGI file with a PHP include


Hey all,

Just trying to include a call to a CGI script with a PHP include on a static PHP page. Here is what I’m trying:

<?php $path = $_SERVER['DOCUMENT_ROOT']; include("$path/to/script/hello.cgi"); ?>

I can hit that script, but the results are the content of the script that I’m trying to include:

#!/usr/bin/perl # hello.cgi - simple script to test if perl is working print “Content-type: text/html\n\n”; print “Hello World from hello.cgi”; exit;

Anyone know if there is something that I should adjust to get this to work?



Read the documentation:
“The include() statement includes and evaluates the specified file.”

In order for a Perl script to generate output, it must be executed. You’re not going to be able to do what you what using the include() statement.

If the Perl script is CGI, then you will need a web server that will execute a Perl interpreter. A web server does so by handling HTTP requests for URLs to the Perl script. Thus you will need an HTTP client library that will submit a request to a web server. And that is where CURL comes in.

:cool: Perl / MySQL / HTML+CSS


Brilliant, thanks!

This worked like a dream, and I appreciate the link to the Wiki. I didn’t even know that existed :slight_smile: