I have a php file which executes a shell script
$ip_access = $_GET['ip_access'];
// run knock app
exec("/home/knock.sh ".$ip_access);
however when I access it I receive the following error in the logs "sh: /home/knock.sh: Permission denied"
I created a new user and added it in the apache httpd.conf file but is still not working . Any advice how to set the permissions or how can I grant more access to the user to make it work would be highly appreciated .
Answer
If you are running the script as the appropriate user, you may need to add the execute permission +x
to the file. You can do it using:
chmod +x /home/knock.sh
As an alternative, you can use the following command (no need to add execute permission):
exec("bash /home/knock.sh ".$ip_access);
No comments:
Post a Comment