[comp.unix.ultrix] can't do stty speed into a pipe or file on Ultrix 3.x

idallen@watcgl.waterloo.edu (09/23/89)

From: "Ian! D. Allen [CGL]" <idallen>

% stty speed
9600
% set speed=`stty speed`
stty: : Not a typewriter

Sure makes it hard to use stty to get your terminal baud rate.

D. Allen [CGL]) (09/25/89)

Let me clarify, for those who think I don't understand stty:

    > % stty speed
    > 9600
    > % set speed=`stty speed`
    > stty: : Not a typewriter
    > 
    > Sure makes it hard to use stty to get your terminal baud rate.

Looking at the Ultrix 3.1 stty source, I confirmed that all ioctl calls
are done on unit 1 (stdout), with almost all stty output going on unit 2
via fprintf(stderr...).  The "size" and "speed" options are the two
exceptions.  Both of these try to open /dev/tty to do the ioctl and use
plain printf to print on unit 1 (stdout) rather than unit 2 (stderr).

But stty aborts long before it gets to try opening /dev/tty, because it
always tries to do an ioctl on unit 1 first, and dies.

Hence, you can't redirect the printf without also redirecting the source
of the unit 1 ioctl and causing stty to abort immediately.
-- 
-IAN! (Ian! D. Allen) idallen@watcgl.uwaterloo.ca idallen@watcgl.waterloo.edu
 129.97.128.64    Computer Graphics Lab/University of Waterloo/Ontario/Canada

dupuy@cs.columbia.edu (Alexander Dupuy) (09/28/89)

Here's what I had to do to get the terminal speed from ultrix

CSH

	alias stty "sh -c 'stty \!* 2>&1 1>&0'"
	alias ttyspeed "stty |sed -n 's/.*speed \([0-9]*\).*/\1/p'"

KSH

	alias ttyspeed="stty 2>&1 1>&0 | sed -n 's/.*speed \([0-9]*\).*/\1/p'"

Pretty gross, eh?

@alex
--
-- 
inet: dupuy@cs.columbia.edu
uucp: ...!rutgers!cs.columbia.edu!dupuy