Determining Terminal lines/cols via PHP CLI

Posted by eFrane on Stack Overflow See other posts from Stack Overflow or by eFrane
Published on 2012-04-15T16:17:46Z Indexed on 2012/04/15 17:29 UTC
Read the original article Hit count: 182

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about php

Related posts about ssh