not working
$result = shell_exec('cd /home/user/scripts/; sudo su ./testsh.sh');
returns NULL
add
2>&1 to the command
shell_exec('cd /home/user/scripts/; sudo su ./testsh.sh 2>&1');
it says
sudo: no tty present and no askpass program specified
add and
check the whole line
www-data ALL=(root) NOPASSWD: /home/user/script/test.sh
to the file
/etc/sudoers
thanks, it worked
don't forget to set the directory where the script is located
sudo su
it's better to write it without SU
Redy]2>&1
means
output to console including all errors
2 redirected to stream 1
0 — STDIN, 1 — STDOUT and 2 — STDERR
Comments