Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How to determine terminal size when piped data to STDIN?

by hanenkamp (Pilgrim)
on Nov 14, 2003 at 17:42 UTC ( [id://307118]=note: print w/replies, xml ) Need Help??


in reply to How to determine terminal size when piped data to STDIN?

I don't know if this is a typical option, but my man-page for stty shows a --file option where you can pick the file to check the parameters on. So, on Linux I can do this:

echo foo | perl -e '$x=`stty -a --file=/dev/stdin`; print "\$x=$x\n";'

and get:

speed 38400 baud; rows 50; columns 131; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = + ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixo +n -ixoff -iuclc -ixany -imaxbel opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs +0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -ec +hoprt echoctl echoke

Since my Unix experience is pretty well limited to Linux, I can't be much help on other platforms.

Update: I made a mistake, I used /dev/stdout in my actual test but wrote /dev/stdin here. If you have access to any console device and a --file option, it would work. However, as mushu points out below, that is not the case.

Replies are listed 'Best First'.
Re: Re: How to determine terminal size when piped data to STDIN?
by mushu (Initiate) on Nov 15, 2003 at 00:58 UTC
    HP-UX doesn't appear to have the --file option for its stty command. BUT, it probably wouldn't matter, since it would be called as a child process, and children inherit their parent's environment, thus STDIO for the stty child process would be the same as the parent's STDIO and not readable either.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://307118]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-03-29 00:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found