Xref: utzoo comp.unix.questions:24594 comp.unix.wizards:23411 Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!me!sun From: sun@me.utoronto.ca (Andy Sun Anu-guest) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: get terminal speed from shell script Message-ID: <90Aug13.095129edt.18647@me.utoronto.ca> Date: 13 Aug 90 13:51:41 GMT References: <90Aug12.135618edt.18763@me.utoronto.ca> <1990Aug13.005849.23223@jarvis.csri.toronto.edu> Organization: University of Toronto, Department of Mechanical Engineering Lines: 56 In article <1990Aug13.005849.23223@jarvis.csri.toronto.edu> ruhtra@turing.toronto.edu (Arthur Tateishi) writes: >In artcle <90Aug12.135618edt.18763@me.utoronto.ca> sun@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@zero.cdf.utoronto.edu Will they ever home on a standard on this one? (sighed) Andy _______________________________________________________________________________ Andy Sun | Internet: sun@me.utoronto.ca University of Toronto, Canada | UUCP : ...!utai!me!sun Dept. of Mechanical Engineering | BITNET : sun@me.utoronto.BITNET