[comp.unix.wizards] how to check port settings on a Sun

kevind@cs.albany.edu (Kevin M. Dombroski) (05/23/91)

Folks,
	How do I change/check the port settings on a Sun 3/50? I've been told
"stty mode > /dev/ttya" will change the settings; how do I check this? I've
tried "stty -a < /dev/ttya", which has no effect. Please let me know. Thanks.


					bosco

larry@st-andy.uucp (Larry Martell) (05/24/91)

In article <837@hartmanis.albany.edu> kevind@cs.albany.edu (Kevin M. Dombroski) writes:
>Folks,
>	How do I change/check the port settings on a Sun 3/50? I've been told
>"stty mode > /dev/ttya" will change the settings; how do I check this? I've
>tried "stty -a < /dev/ttya", which has no effect. Please let me know. Thanks.

The BSD stty (which you will run by default - it's in /bin) will not change
or check the settings of anything other then the tty you are executing it
from. The System V stty (it lives in /usr/5bin), however, will do exactly 
what you want. To change port settings execute: 
	"/usr/5bin/stty mode > /dev/ttya". 
To check the settings run: 
	"/usr/5bin/stty < /dev/ttya".

When I came from System V to SunOS 5 years ago I had the same problem.
-- 
Larry Martell                  "Opinions are like assholes; everybody has one, 
212-668-9478		        but nobody wants to look at the other guys"
uunet!st-andy!larry

hedrick@athos.rutgers.edu (Charles Hedrick) (05/25/91)

>The BSD stty (which you will run by default - it's in /bin) will not change
>or check the settings of anything other then the tty you are executing it
>from.

huh?  Some experiments with SunOS 4.1.1 show that the BSD stty will
manipulate other tty's if you use >/dev/ttyNN (it prints on stderr),
whereas Sys5 stty will do so if you use </dev/ttyNN.  This is the
traditional difference between BSD and Sys5 stty.

adrianho@barkley.berkeley.edu (Adrian J Ho) (05/25/91)

In article <1991May23.191124.359@st-andy.uucp> larry@st-andy.uucp (Larry Martell) writes:
>In article <837@hartmanis.albany.edu> kevind@cs.albany.edu (Kevin M. Dombroski) writes:
>>Folks,
>>	How do I change/check the port settings on a Sun 3/50? I've been told
>>"stty mode > /dev/ttya" will change the settings; how do I check this? I've
>>tried "stty -a < /dev/ttya", which has no effect. Please let me know. Thanks.

>The BSD stty (which you will run by default - it's in /bin) will not change
>or check the settings of anything other then the tty you are executing it
>from.

Huh?  Works fine for me (/dev/ttya is hooked up to a VT220):

# stty -a > /dev/ttya
[...]
isig iexten icanon -xcase echo echoe echok -echonl -noflsh -tostop
[...]
# stty -echo > /dev/ttya
# stty -a > /dev/ttya
[...]
isig iexten icanon -xcase -echo echoe echok -echonl -noflsh -tostop
[...]

>	The System V stty (it lives in /usr/5bin), however, will do exactly 
>what you want. To change port settings execute: 
>	   "/usr/5bin/stty mode > /dev/ttya". 

RTFM, and make that:
	/usr/5bin/stty mode < /dev/ttya
Your way will _really_ set "mode" on the tty you're executing it from.

Kevin's problem was in the way he was _querying_; he should have done:
	stty -a > /dev/ttya

--
-----------------------------------------------------------------------------
Adrian Ho, EECS (pronounced "eeks!") Dept.		Phone: (415) 642-5563
UC Berkeley					adrianho@barkley.berkeley.edu

mouse@thunder.mcrcim.mcgill.edu (der Mouse) (05/29/91)

In article <1991May23.191124.359@st-andy.uucp>, larry@st-andy.uucp (Larry Martell) writes:
> In article <837@hartmanis.albany.edu> kevind@cs.albany.edu (Kevin M. Dombroski) writes:
>> How do I change/check the port settings on a Sun 3/50?  [...]
> The BSD stty (which you will run by default - it's in /bin) will not
> change or check the settings of anything other then the tty you are
> executing it from.

Then it's not a real BSD stty; Sun must have broken it.  Real Berkeley
stty ("@(#)stty.c      5.4 (Berkeley) 4/4/86") does most of its ioctls
to file descriptor 1, meaning it will print/change the settings of its
stdout.  (Exceptions: "stty size" and "stty speed" explicitly use
/dev/tty for some inscrutiable reason.)

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

guy@auspex.auspex.com (Guy Harris) (05/30/91)

(Hmm.  Distribution: usa, but you got a copy.  Did we annex you and just
not tell anybody?  Or did you annex us?  :-))

>> The BSD stty (which you will run by default - it's in /bin) will not
>> change or check the settings of anything other then the tty you are
>> executing it from.
>
>Then it's not a real BSD stty;

Well, if it's SunOS 4.x, no, it's not a real BSD "stty"; it's a System V
Release 3.1 "stty" with some changes:

	1) #ifdeffed code so that it can be compiled to use its file
	   descriptors BSD-fashion (set/get mode of stdout, print modes
	   on stderr) or S5-fashion (set/get mode of stdin, print modes
	   on stdout), the former being "/usr/bin/stty" and the latter
	   being "/usr/5bin/stty";

	2) added special characters and mode bits for the BSDish
	   additions (which came from a proposal to POSIX; Sun didn't
	   invent them, and they're also showing up in 4.3-reno, System
	   V Release 4, AIX 3.1, and probably others hopefully including
	   OSF/1);

	3) added some additional aliases and combined modes to support
	   BSDish settings (e.g., "cbreak" == "-icanon");

	4) added support for "stty size" and "stty speed".


> Sun must have broken it.

No, the poster is just confused; perhaps they didn't know what file
descriptor it acts on, 'cuz "/usr/bin/stty" can have its standard output
redirected to another terminal to change its modes (if you have
permission to do so).

> Real Berkeley stty ("@(#)stty.c      5.4 (Berkeley) 4/4/86") does most
> of its ioctls to file descriptor 1, meaning it will print/change the
> settings of its stdout.  (Exceptions: "stty size" and "stty speed"
> explicitly use /dev/tty for some inscrutiable reason.)

Well, actually, that's one thing that *was* broken in SunOS 4.0,
although 4.1 fixes it.

The standard "print a mode" and "set the modes" stuff acts on file
descriptor 1 because the V7 "stty" worked that way; it may have worked
that way because, in older UNIXes (V7, BSD before 4.3BSD, System V
before SVR4) user's terminals were publicly writable, but not publicly
readable, and they may have wanted to let people repair the settings on
other people's terminals without becoming super-user; you couldn't
redirect the input of "stty" to somebody else's terminal, but you could
redirect its output.  (If somebody such as DMR is listening, could they
confirm or deny this hypothesis?)

Unfortunately:

1) that also lets you *damage* the settings on other people's terminals,
   if they haven't done "mesg n" to deny write permission;

2) it doesn't help on systems that don't make terminals publicly
   writable, e.g. 4.3BSD and later, and systems that have picked up the
   4.3BSD notion, including, I think, System V Release 4;

3) it makes it a pain to send the output of "stty" elsewhere, since it
   goes to the standard *error*, not the standard *output*, as the
   standard output may be going to another terminal.

I think the output of "stty size" and "stty speed" is often captured and
redirected, e.g. `stty speed`; Berkeley presumably made it act on
"/dev/tty" so that it would work if its standard output were redirected
to, say, a pipe, as in `stty speed`.  SunOS 4.0[.x] still acts on the
standard output in that case, which doesn't work, but 4.1 fixes that.

S5 acts on its standard input, so that's not a problem there; its output
can be redirected elsewhere, and it even has a flag to dump its settings
in an encoded form that can also be used to restore the settings.  I
suspect that stuff may be in POSIX 1003.2, so BSD may pick it up.