Re: system, exec, shell_exec, passthru
| From: | Adam Zey | Date: | Mon, 14 Aug 2006 17:43:25 +0000 |
| Subject: | Re: system, exec, shell_exec, passthru | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-240645@lists.php.net to get a copy of this message | ||
Michael Jonsson wrote:
Hi,
I can run any external program like ls, cp, uptime...
But if a try to run my shell script a get error.
$passwdexe = "sudo /usr/bin/webpasswd";
$user=$_POST[name];
$passwd="$passwdexe $user 123456";
echo $passwd;
$result = system($passwd);
Resultat from the web, "sudo /usr/sbin/webpasswd billy 12345678"
and from the error_log, "couldn't read file "./usr/sbin/webpasswd.": no such file or directory".
.Mike
Notice that "." is being appended before the path, which turns it into a relative path. It looks like safe mode might be on.
Create a new PHP script with nothing but the command "phpinfo();" in it, and view it in a browser. To see if safe mode is on, look for the setting "safe_mode". The line below it is "safe_mode_exec_dir". If safe mode is on, you'll need to put your program ("webpasswd") into that directory to execute it.
Regards, Adam Zey.