bash - execute shell command with php -
im trying execute bash script php/html
button wake nas.
<form action="" method="post"> <input type="submit" value="wake nas" name="zero" /> </form> <?php if (isset($_post["zero"])){ #echo "hello world!"; shell_exec("/var/www/html/wakenas.sh &"); }?>
"hello world" printed when button pressed. code won't executed. wakenas.sh
looks , works if execute on shell
#!/bin/bash etherwake -d "bc:5f:f4:09:e1:07" echo "why!?!?!" > "/var/www/html/works.txt" exit 1
wakenas.sh
has rights
maybe guys know why wont executed.
thanks in advance
from dump:
etherwake: program must run root.
when execute wakenas.sh executing root. that's why works.
give sudo permission (without password) user php server running.
and change wakenas.sh to:
#!/bin/bash sudo etherwake -d "bc:5f:f4:09:e1:07" echo "why!?!?!" > "/var/www/html/works.txt" exit 1
Comments
Post a Comment