calling php from perl
| From: | peter beardsley | Date: | Mon, 18 Dec 2000 16:14:26 +0000 |
| Subject: | calling php from perl | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-30925@lists.php.net to get a copy of this message | ||
Hi,
What I'm trying to accomplish is including the output of a php script in a perl CGI. The output of a perl/mod_perl CGI is not parsed by php, so I tried calling the php executable and printing the output, ala:
#!/usr/bin/perl
## note: backticks in perl execute a command and returns stdout.
print
/usr/local/bin/php -f /home/httpd/cgi-bin/test.php;
The contents of the test.php file is a simple:
<?php print "hello world.\n" ?>
What happens is PHP is smart enough to know that it's being called in a CGI context, and I get the following output in a browser:
X-Powered-By: PHP/4.0.3pl1 Content-type: text/html No input file specified.
If I run the perl script from the command line, it works fine. It's weird because I'm definitely specifying an input file with the "-f". I've tried many variations on this in perl including system(), various pipe and temp file hacks to no avail. I've poked around in the sources a bit and I think what's happening is that php is looking for a CGI parameter to specify an input file, and it's not there.
Does anyone know how to work around this or an entirely different approach altogether?
Thanks,
Peter Beardsley
Appropriate Solutions Inc.
pbeardsley@appropriatesolutions.com
(603)924-6079