I'm currently trying to build a screen manager for my V-Server (running Debian 6.0.6) using PHP.
My script does already show the runnung screens, but I just fail at running a new screen:
webstat.php:
exec('sudo -u root screen -ls',$result);
print_r($result);
Added to sudoers (I know that this is unsecure, but it's easier in the testing phase):
www-data ALL=(ALL) NOPASSWD: ALL
Here is the code I've tried to run a PHP-file in a new screen:
exec('sudo -u root screen -S screenId php /var/www/script.php parameter1=1',$result);
print_r($result);
This just outputs "Must be connected to a terminal.", but using SSH this command is working perfectly.
Next I read about the SSH-command and tried this command:
sudo -u root ssh -t root@box screen -S screenId php /var/www/script.php parameter1=1
That command worked using PuTTY, but when I use this command in PHP it gives no result nor starts a new screen session:
exec('sudo -u root ssh -t root@box screen -S screenId php /var/www/script.php parameter1=1',$result);
print_r($result);
There are no functions disabled on my V-Server. I don't want to write a bash-script which I call with PHP, I want to execute the commands directly with PHP.
It would be nice if someone knows how to fix this problem!