[PHP] shell_exec: sudo: no tty present and no askpass program specified

10/19/2013 03:55 Coniesan#1
Hey @ all, ich komm gleich mal zur Sache

1. ich möchte, dass mein Script eine shell/batch File executed
2. ich benutze: Linux Debian 6 | Apache2.4 | PHP 5.4.17
3. mein Command
PHP Code:
$execute_shell=shell_exec('sudo sh /home/usr/scripts/apache.sh 2>&1');
echo 
$execute_shell
4. Fehlercode:
Code:
no tty present and no askpass program specified
5. sudoers:
Code:
Defaults !requiretty
www-data ALL=(ALL:ALL) NOPASSWD: /home/usr/scripts/apache.sh
(ja ich hab schon mit whoiam gecheckt, dass es www-data ist!)


Wär echt chillig, wenn mir jemand helfen könnte, oder einer ne Idee hat, woran das Ganze liegen kann!

Kind regards
10/19/2013 16:10 Luxxus²#2
hey,
Hast du es mal so probiert?

PHP Code:
shell_exec('ssh -t HOST sudo sh /home/usr/scripts/apache.sh 2>&1'); 
10/19/2013 16:20 Coniesan#3
Hey, erstmal thx für die Antwort, jetzt kommt aber diese Meldung....:
Code:
Pseudo-terminal will not be allocated because stdin is not a terminal. ssh: connect to host luki4fun port 22: Connection timed out
10/19/2013 16:23 Luxxus²#4
Ups, so war das nicht gemeint :P
Versuch mal so:

PHP Code:
shell_exec('ssh -t localhost sudo sh /home/usr/scripts/apache.sh 2>&1');