Operating System - HP-UX
1826073 Members
3410 Online
109690 Solutions
New Discussion

Re: setting tty default values

 
SOLVED
Go to solution
John Rowan_1
Occasional Advisor

setting tty default values

I am not able to permanently set tty default values using stty. Port setting return to original defaults when re-opened or re-initialized. Is there a way to permanently change defaults.
5 REPLIES 5
steven Burgess_2
Honored Contributor
Solution

Re: setting tty default values

Hi

You need to put the new settings in your startup files, for all users /etc/profile. For a single user in their home directory

~/.profile

Regards

Steve
take your time and think things through
steven Burgess_2
Honored Contributor

Re: setting tty default values

Hi John

An example in my .profile on our test server

# Set up the terminal:
if [ "$TERM" = "" ]
then
eval ` tset -s -Q -m ':?hp' `
else
eval ` tset -s -Q `
fi
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty hupcl ixon ixoff
tabs

Steve
take your time and think things through
Wodisch
Honored Contributor

Re: setting tty default values

Hi,

the default "stty" values of serial ports are defined by the programmers of the serial device drivers!
Hence you cannot change them (except for reprogramming and installing them, then rebooting)...

Just my $0.02,
Wodisch
Bill Hassell
Honored Contributor

Re: setting tty default values

Let's start with the basics. stty will change the values for the port you specify. If you don't specify any port, it will change stdin. However, stty opens the port you specify, makes the changes and then closes the port. If the port is not also opened by another process, the settings revert to their default values (ie, 300 baud, etc).

So if you type an stty command at your shell prompt (with no device file) then it will affect your current tty device and the value(s) will stick because the tty port is currently opened by the shell. When the shell exits, the tty settings revert back to default.

If you wish to change a specific port, for instance, a serial barcode reader or similar, you need to keep the port open. This technique was real common for printers in the good old days:

nohup sleep 999999 < /dev/tty2p4 &
stty raw 9600 -parenb cs8 ixon -istrip clocal
The sleep command opens the tty port and then sleeps (for a long time), keeping the port open. So, as long as the sleep command is active, the settings will stay.


Bill Hassell, sysadmin
T. M. Louah
Esteemed Contributor