get terminal speed from shell script

Gerry Roderick Singleton gerry at jts.com
Wed Aug 15 04:10:10 AEST 1990


In article <90Aug13.095129edt.18647 at me.utoronto.ca> sun at me.utoronto.ca (Andy Sun Anu-guest) writes:
>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`

[lines deleted]

>
>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.

[more lines deleted]

>>other than a proper tty device, I came up with the following.
>>		speed=`stty speed 3>&2 2>&1 1>&3` 

[more lines deleted]


I like to add my two penny's worth,  to query the speed of the tty device
shouldn't one accept input from the device rather than perform output
to it before getting the answer?  The question is rhetorcal so don't bother
answering it.  It apppears to me to be valid in this case for BSD4.3 running
on an ISIv24.  Here's my little sample:


#! /bin/sh

speed=`stty speed </dev/tty 2>&1`
echo $speed


and the results:

 /usr/local/src >%[530] sh -vx foo
 #! /bin/sh
  
  speed=`stty speed </dev/tty 2>&1`
  + stty speed 
  speed=9600
  echo $speed
  + echo 9600 
  9600
   /usr/local/src >%[531] 

I believe this satisfies Andy's requirements and I hope it's what he wanted.
Anyways it'll fuel the discussion.

Cheers,
ger
-- 
--
G. Roderick Singleton, System and Network Administrator, JTS Computers 
	{uunet | geac | torsqnt}!gerry at jtsv16.jts.com



More information about the Comp.unix.wizards mailing list