I have a PHP file with shell commands running through a screen, the commands run fine but I was wondering if there was a way to get this to output to PHP without writing to another file and reading it on PHP's end.
PHP - trace() is just a fancy print_r()
$cmd = 'ls -h /';
trace(shell_exec('screen -S output -p 0 -X stuff "`echo '.$cmd.'\'
\'`"'));
Web output
NULL
Screen output
www-data@:/home/ubuntu$ ls -h /
bin build etc initrd.img lib media opt root selinux sys usr vmlinuz
boot dev home initrd.img.old lost+found mnt proc sbin srv tmp var vmlinuz.old
Any suggestions?
--Edit--
Certain commands aren't outputting directly, one of the reasons I'm using screen
PHP
$cmd = 's3ls';
trace(shell_exec('screen -S output -p 0 -X stuff "`echo '.$cmd.'\'
\'`"'));
trace(shell_exec($cmd));
Web output
trace:NULL
trace:NULL
Screen
www-data@:/home/ubuntu$ s3ls
+---------------+--------------------------+
| Name | CreationDate |
+---------------+--------------------------+
| bucket | 2012-05-31T13:08:51.000Z |
| bucket | 2012-01-17T16:51:58.000Z |
| bucket | 2012-03-31T11:19:54.000Z |
+---------------+--------------------------+