Hi,
want to call a PHP prog (written as a cgi and using the shebang etc) from perl.
used:
$a=`/usr/local/php/bin/php /home/useridz/http/testphp.php -q fred=testing`;
but cant get the vars to get across to the PHP mod. The PHP cgi works fine otherwise - returns info it but doesnt see the input variables.
globals is on but $argv is empty and $argc is 0
any ideas anyone ?
cheers
Jim
Calling PHP cgi from Perl
Moderator: General Moderators
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
yep - tried it with and without the -q - get the same results - eg:
$a=`/usr/local/php/bin/php /home/ozbcoz/http/testphp.php fred=testing`;
print "$a";
with the php script showing:
#!/usr/local/php/bin/php -q
<?
$v=$HTTP_POST_VARS;
$g= $HTTP_GET_VARS;
$p= $HTTP_POST_FILES;
print "<br>POST_VARS = ";
var_dump($v);
print "<br>GET_VARS = ";
var_dump($g);
print "<br>POST_FILES = ";
var_dump($p);
print "count=$argc<br>";
print "0=$argv[0]<br>";
print "1=$argv[1]<br>";
print "2=$argv[2]<br>";
phpinfo();
?>
the outout comes out as:
POST_VARS = array(0) { }
GET_VARS = array(0) { }
POST_FILES = array(0) { } count=0
0=
1=
2=
plus the phpinfo bumpf
cheers
Jim
$a=`/usr/local/php/bin/php /home/ozbcoz/http/testphp.php fred=testing`;
print "$a";
with the php script showing:
#!/usr/local/php/bin/php -q
<?
$v=$HTTP_POST_VARS;
$g= $HTTP_GET_VARS;
$p= $HTTP_POST_FILES;
print "<br>POST_VARS = ";
var_dump($v);
print "<br>GET_VARS = ";
var_dump($g);
print "<br>POST_FILES = ";
var_dump($p);
print "count=$argc<br>";
print "0=$argv[0]<br>";
print "1=$argv[1]<br>";
print "2=$argv[2]<br>";
phpinfo();
?>
the outout comes out as:
POST_VARS = array(0) { }
GET_VARS = array(0) { }
POST_FILES = array(0) { } count=0
0=
1=
2=
plus the phpinfo bumpf
cheers
Jim
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
If you have a sha-bang in the script and the script is executable you can invoke the script directly, ie in perl
$a = `/home/ozbcoz/http/testphp.php fred=testing`;
I don't know what, if any parsing it will do with the fred=testing, I suspect that it argv[1] will equal "fred=testing" as command-line arguements are space delimited.
I have a script that I use in cron as /usr/local/bin/compinabox/rebuild_stats.php arguement
the script starts
Does this help at all?
$a = `/home/ozbcoz/http/testphp.php fred=testing`;
I don't know what, if any parsing it will do with the fred=testing, I suspect that it argv[1] will equal "fred=testing" as command-line arguements are space delimited.
I have a script that I use in cron as /usr/local/bin/compinabox/rebuild_stats.php arguement
the script starts
Code: Select all
#!/usr/local/bin/php
<?php
if ($argvї1]=="") die ("Usage: foo....");
?>