get terminal speed from shell script
Arthur Tateishi
ruhtra at turing.toronto.edu
Mon Aug 13 14:58:49 AEST 1990
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.
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.
--
``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
More information about the Comp.unix.wizards
mailing list