jimr390
asked on
Executing PHP from Perl - source code is displaying
Hi,
Here's what is happening:
I have a php script which runs fine from the command line, and via the web. I'd like to call the script from a perl cgi, to get the results (it's ugly, but would be a simple solution to our problem) of it.
What happens is very strange. At the point where the php script is supposed to execute, basically, the entire contents of the script are printed out (the script didn't execute) and the perl script seems to bomb out as well. So on the web page, i see the entire source code to the php script, and also some code from the perl script. It's really bizarre.
Any ideas on what is causing this? I'm fairly experienced at perl, cgi, etc., and have tried many tricks to see what might work.
-Jim
Here's what is happening:
I have a php script which runs fine from the command line, and via the web. I'd like to call the script from a perl cgi, to get the results (it's ugly, but would be a simple solution to our problem) of it.
What happens is very strange. At the point where the php script is supposed to execute, basically, the entire contents of the script are printed out (the script didn't execute) and the perl script seems to bomb out as well. So on the web page, i see the entire source code to the php script, and also some code from the perl script. It's really bizarre.
Any ideas on what is causing this? I'm fairly experienced at perl, cgi, etc., and have tried many tricks to see what might work.
-Jim
ASKER
Ok, the script runs fine from the command line as you show (perl -e 'print `php /php/version.php`')
The problem is running it through the browser as a cgi, then the php callout (using `` or open, doesn't matter) shows source code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are using open in perl, then you are simply opening the php file (for example like you would in a text editor) and all you will get is the contents.
if you use the command
print `php /php/version.php`
in your CGI page that should work as you expect
if you use the command
print `php /php/version.php`
in your CGI page that should work as you expect
ASKER
Well, actually, I was doing an open with a |, which should execute the code and give me stdout.
Anyway, as it turns out, we are abandoning our approach and taking a different tact. So, the point is moot.
I'll close this out and divide up the points to those who responded - thanks for trying to help.
-Jim
Anyway, as it turns out, we are abandoning our approach and taking a different tact. So, the point is moot.
I'll close this out and divide up the points to those who responded - thanks for trying to help.
-Jim
you may give us the example how you are doing the exec within perl, so we can see what the problem may be with your code.
The following gives me the output of the execute php-script not the source-code
perl -e 'print `php /php/version.php`'