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 |