When calling a php file which consists of:
<?php system('/bin/sh /usr/local/bin/myScript.sh '.'myArg'); ?>
from cli through
php myScript.php everything runs fine however when doing the work through cgi, opening the url within the browser (apache without anyone's knowledge)
myArg string will get lost.
Does anybody knows what is failing?
PD: myScript.sh is simply an
echo "$# $*" >> /tmp/foo.txt
so a tail /tmp/foo.txt shows everything works fine from cli although not from apache's cgi. Will I need any other configuration in php.ini? Will i need anything special during my apache alias file? Could it be boodoo?
In case your code is really as you listed it above,
'myArg' won't be lost. However, if you're inhabiting the argument dynamically, you will have to make sure that you collect the argument in ways that actually works properly for that calling method.
Whenever you execute the script using a browser, you are able to collect arguments via
$_POST. Whenever you execute the script via CLI, the arguments is going to be present in
For those who have verified that you will get the right value for that argument, the next thing is to check on permissions. Be sure that the CLI user has permissions to complete the command using the argument specified.
Has user running apache spend ? Make sure, that inside your /etc/passwd has that user (automatically 'nobody') a spend /bin/party or /bin/sh (it's last argument (arguments are separated by semicolons))