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.


In reply to Re: How to determine terminal size when piped data to STDIN? by hanenkamp
in thread How to determine terminal size when piped data to STDIN? by mushu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.