Phpexec failed to run linux commands! Please help! Environment: javastuserver & nbsp; scenario: use a web page to modify samba user passwords. for example, PHPcodeexec (& quot; echo-e \ & quot; 0 \ n0 \ n \ & q php exec failed to run linux command! Please help!
Environment: ubuntu server
Scenario: use the web page to modify the samba user password
Detailed description: for example:
PHP code
exec("echo -e \"0\\n0\\n\"|sudo smbpasswd -as test3");
When I run the following error on the php page:
Mismatch-password unchanged.
Unable to get new password.
That is to say, no modification is successful.
But when I run the commands in the system command line, it will succeed!
The following is a command that runs directly in the command line. nobody is my apapche user. The following is a command run by an apache user.
PHP code
sudo -u nobody echo -e "0\n0\n"|sudo smbpasswd -as test3
What is the reason for this?
------ Solution --------------------
Permission problems?
What if I use sudo permission to execute your php file?
------ Solution --------------------
Exec ("echo-e \" 0 \ n0 \ n \ "| sudo smbpasswd-as test3 ");
Double quotation mark nesting error. it is not necessary to use a shell file and then call
Exec ('echo-e \ "0 \ n0 \ n \" | sudo smbpasswd-as test3 ');