get terminal speed from shell script
Andy Sun Anu-guest
sun at me.utoronto.ca
Mon Aug 13 23:51:41 AEST 1990
In article <1990Aug13.005849.23223 at jarvis.csri.toronto.edu> ruhtra at turing.toronto.edu (Arthur Tateishi) writes:
>In artcle <90Aug12.135618edt.18763 at me.utoronto.ca> sun at me.utoronto.ca (Andy Sun Anu-guest) writes:
>
>>Is there a way to get the terminal speed from a (sh or csh) script?
>>I used to be able to do the following in a Bourne shell script:
>> speed=`stty speed`
>>and got the terminal speed assigned to variable speed. As various OS
>>gets updated (e.g. Ultrix 3.1 and SUN OS 4.0.3), this won't work anymore
>>because all stty outputs are being sent to stderr, not stdout, thus no
>>piping or redirection is possible. Is there any similar commands that can
>>get terminal speed inside a shell script?
>
>I find it odd that the SUN man pages still specify option info is output
>on stdout... Maybe I shouldn't be surprised.
>
I guess it depends on which version of SUN OS. "speed=`stty speed`" works
for a Sun 3/60 running (I think) SUN OS 3.x. So it does went through stdout.
I tried the same thing on a SPARCstation running Sun OS 4.0.3c and it
gave me "Operation not supported on socket". What you suggested below, i.e,
"speed=`stty speed 2>&1 1>/dev/tty` works on the SPARCstation.
>However, I since stty seems to go bonkers when stdout goes to something
>other than a proper tty device, I came up with the following.
> speed=`stty speed 3>&2 2>&1 1>&3`
>This essentially swaps stdout and stderr with a dangling file descriptor 3
>which could be closed with 3>&- however it shouldn't matter. Be warned,
>if stderr has been modified to be a socket going somewhere, it will likely
>blow up with 'stty: Operation not supported on socket.' so you could use
> speed=`stty speed 2>&1 1>/dev/tty`
>which also has its drawbacks.
>Sorry, I can't confirm this for Ultrix.
I confirmed it, neither works :-)
speed=`stty speed` gave me "Not a typewriter" and
speed=`stty speed 2&1 1>/dev/tty` echoes the speed on the screen but assigns
nothing to the variable speed. I don't know why it works for SPARCstation
because I think /dev/tty is not the same as stdout. If in a C program you
specify /dev/tty as your output stream instead of stdout, everything echoes
on the screen in both cases but you cannot use redirection with /dev/tty.
>
>--
>``Sex and drugs? They're nothing compared with a good proof!''
> - A Cambridge student (r.h.f)
>Arthur Tateishi g9ruhtra at zero.cdf.utoronto.edu
Will they ever home on a standard on this one? (sighed)
Andy
_______________________________________________________________________________
Andy Sun | Internet: sun at me.utoronto.ca
University of Toronto, Canada | UUCP : ...!utai!me!sun
Dept. of Mechanical Engineering | BITNET : sun at me.utoronto.BITNET
More information about the Comp.unix.questions
mailing list