I have a script which is called from php using the shell_exec command on a server running Ubuntu. The script runs properly when called from the command line via ssh, but not when called from php.

I'm having a really hard time figuring out where it is going wrong and I was wondering if there was a way to run the script from the ssh command line but with the same user account and permissions that php shell_exec will call it with.

Thank you.


Assuming the php user is www-data:

sudo -u www-data /path/to/script

The environment may be different but that probably does not matter.

| improve this answer | |
  • Thank you! You just saved me hours of trying to find out what was going (a permissions issue) – Bar Smith Mar 20 '18 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.