I'm on a hosted Linux system running an Apache server with PHP installed: PHP 4.3.8 (cgi) (built: Aug 31 2004 11:48:16)
Here is a trivial php script (called x) that I can run from the shell prompt:
#!/usr/local/bin/php -q
<?php
printf("Hello World\n") ;
exit(0);
?>
It produces the expected result (a single line with no PHP headers) on stdout
when run from the shell prompt. It works fine completely as intended!
Here is a trivial cgi shell program (called xwrap2) that will execute via URL as http://dinsights.com/POTM/cgi-bin/xwrap2:
#!/usr/bin/ksh
/correct_full_PATH/x > /tmp/out
echo Content-type: text/html
echo
echo "<PRE>"
cat /tmp/out
When I type the above URL, the contents of /tmp/out (when examined via the shell) contain much different output than the expected "Hello World" ... It contains kindof a "listing" of xwrap2:
Content-type: text/html
X-Powered-By: PHP/4.3.8
.... and then the "listing"
I want /tmp/out to contain "Hello World" when I run the cgi via the URL above ... not the listing of the program ... WHAT CAN I DO???
Background: the question is based around the "sandbox" I use to support a programming contest at http://dinsights.com/POTM ... I want to be able to accept entries written in php ... apparently they run just fine from the shell but give this strange behavior when run from within my sandbox cgi.
I do NOT have access to kernel changes or root permissions - I'm on a hosting box as a customer so alternatives like recompiling something with different parameters set are not an option ... (I've tried to read up in the forums and this is the kind of thing that seems to be suggested occasionally) hopefully there will be an alternative!
Thanks in advance for your help!
=Fred (The POTM-MASTER)