2

How to execute /home/scripts/test.sh file in php

Previously i have placed 'test.sh' file in the /usr/bin and calling in my php file like this

exec('test.sh ' . escapeshellarg($testString)); 

But for security reasons i moved .sh file to /home/scripts directory and in my php i am calling like this

exec('/home/scripts/test.sh ' . escapeshellarg($testString)); 

But it is not working now.

Please suggest me how to achieve this.

  • What are the permissions on the /home/scripts dir, the shell script, and what user:group is running php? – Paul Jun 26 '12 at 8:45
1

Check the value of return_var and display the value of output - this will probably tell you that you have the wrong permissions set on either /home, /home/scripts or on /home/scripts/test.sh.

  • i forgot about giving permission to that file just i copied from local system to there, after giving execute permissions it worked. Thanks a lot.... – vvr Jun 27 '12 at 5:46

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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