I'm looking for a way to pipe the output of the *nix screen
command to another program. In theory I would like to be able to do something like:
screen -S test | php testscript.php
and testscript.php receive it through php://stdin
However I am open to other options if necessary.
Asked
Active
Viewed 663 times
0

Jason Plank
- 2,336
- 5
- 31
- 40

Nick Q.
- 3,947
- 2
- 23
- 37
-
Screen opens up a virtual terminal, it's not actually running anything, so there is nothing to pipe into the php script. If you did screen -S test then typed a command like `cat some.log | php test script.php` that would work. Why are you using screen? Can't you just push the process into the background using &? – Mike Purcell Nov 09 '11 at 20:43
1 Answers
1
#!/usr/bin/php
<?php
$fd = fopen("php://stdin","r");
$foo = "";
while ( !feof($fd) ){
$foo .= fread($fd,1024);
}
fclose($fd);
//rest of script
command line: screen -S test |/path/to/php/script.php makes user script file is chmod to 755
-
-
-
Simply put not really. `screen -S test > output.txt` returns nothing, no matter the contents of the screen. However `screen -S test -L` makes a text file called screenlog.n – Nick Q. Mar 25 '11 at 01:00
-
-
looking at what screen does, im not surprised at the results, what is it your actully trying to achieve? – Mar 25 '11 at 03:28