Phpexec failed to run the linux command! Please help

Source: Internet
Author: User
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 ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.