Determining Terminal lines/cols via PHP CLI
- by eFrane
I know that it is quite easy to figure out a terminal's size parameters via the stty -a command. When using local CLI PHP scripts, there is no problem at all on grabbing that output via system() or so.
But I am trying the same thing via a php script started from an ssh command. Sadly, all that stty ever returns is:
stty: standard input: Invalid argument.
The calling code is:
exec('stty -a | head -n 1', $query);
echo $query[0];
So the question is: If I can output to the terminal and read input from it (e.g. can fread() from STDIN and fwrite() to STDOUT in PHP, shouldn't stty also have valid STDIN and STDOUT?