1833325 Members
3072 Online
110051 Solutions
New Discussion

Re: login prompt Qn #1

 
Shahril M
Frequent Advisor

login prompt Qn #1

Hi,

On some boxes, if I mistype the login id or password before I hit , I can type @ and start over as thought the previous characters were never typed at all.

I would like to learn how this is set up.

TIA,
Shahril
11 REPLIES 11
harry d brown jr
Honored Contributor

Re: login prompt Qn #1


You mean like the behaviour of

stty kill @

??

live free or die
harry
Live Free or Die
Bill Hassell
Honored Contributor

Re: login prompt Qn #1

The default behavior for login is different than at a shell prompt. The # sign is a backspace while the @ symbol cancels the line. stty in /etc/profile doesn't have any effect on the login and password strings.

However, you can change every login (serial, modem, telnet, etc) by using this construct:

stty erase "^H" < /dev/ttyconf

This will set the driver options for all connections prior to login. It takes effect immediately except for the serial console port which will require a reboot. This works on current versions of HP-UX with appropriate patches.


Bill Hassell, sysadmin
Shahril M
Frequent Advisor

Re: login prompt Qn #1

Hi Bill, Harry & others,

stty -a reports the current option settings.

How do I inspect the default settings so that if I do not like the behaviour of my "stty .... < /dev/ttyconf" command, I can revert it?

Also, is kill the option for "cancel line"?


TIA,
Shahril
ps. been away for a while
harry d brown jr
Honored Contributor

Re: login prompt Qn #1


Yes, stty kill ^U "cancel's" the line

If you change the behaviour and you don't like it, just change it back.

If you do it just for your session, when you logout, it will be reset.

live free or die
harry
Live Free or Die
Wodisch
Honored Contributor

Re: login prompt Qn #1

Hi Shahril,

to see the "default" settings simply do an "stty sane" first, then the already mentioned "stty -a".
HP-UX uses the very classical convention of "kill ^@", but Solaris and Linux do not!

HTH,
Wodisch
Shahril M
Frequent Advisor

Re: login prompt Qn #1

Hi Harry, Wodisch & others,

So far, I have tested based on Bill's post that to effect what I want to achieve, I have to use /dev/ttyconf.

I tried "stty erase ^H < /dev/ttyconf". Before, I was unable to backspace on the login prompt, now I can.

Then, Harry confirmed that kill is the option that I want to use.

However, I am hesitant to try it out until I can check what is the existing value. I am hesitant because I do not want to avoid being unable to use @ in my mailx commands.

Wodisch, unfortunately "stty -a" is not answer because it only displays the current session, not the tty default Bill was writing about.

I have confirmed this as the values of kill (and erase too) are the same for 2 machines, where one allows me to use @, the other does not.

TIA,
Shahril
ps. Harry, congrats on your achievement.

Shahril M
Frequent Advisor

Re: login prompt Qn #1

Hi folks,

If I may resurrect this thread ....

Now, the flwg command achieves my objective:
stty kill @ < /dev/ttyconf

What I still want to know is, how do I inspect the current default settings so that I know what to revert to if I wish to undo my command.

Now, based of the previous posts:
1) stty -a show the current session-specific settings
2) stty sane, followed by stty -a gives a different output, but not exactly the default settings. How did I arrive at this conclusion?:

On a server for which the @ entry does not cancel line, stty sane followed by stty -a gave the value of kill as @:
kill = @

After issuing stty kill @ < /dev/ttyconf, the value of kill remains as @. But now the @ entry cancels the line during login entry.

Thus, there is no difference in output. So, what command should be used instead?


Rgds,
Shahril
Bill Hassell
Honored Contributor

Re: login prompt Qn #1

> Now, the flag command achieves my objective:
> stty kill @ < /dev/ttyconf

Not a very useful setting, especially for email addresses, but OK.

> What I still want to know is, how do I inspect the current
> default settings so that I know what to revert to if I wish
> to undo my command.

stty -a


> Now, based of the previous posts:
>
> 1) stty -a show the current session-specific settings

Correct.


> 2) stty sane, followed by stty -a gives a different output,
> but not exactly the default settings.

Correct. stty sane is not useful at all. The "sane" settings are leftover from the days of Teletypes and papertape. I would not use stty sane since you need to change several settings.

> After issuing stty kill @ < /dev/ttyconf, the value of kill
> remains as @. But now the @ entry cancels the line during
> login entry.

A couple of things:

stty settings using /dev/ttyconf take place immediately for all logins *EXCEPT* for the console. The console requires a reboot.

The default settings are changed in the standard login profile (/etc/profile) so if you issue the stty/ttyconf command, /etc/profile (and possibly .profile) may have an stty command which changes the current session.

The /dev/ttyconf technique is used primarily to control login behavior (when typing the username and password). The stty settings for sessions after the login is complete are set in /etc/profile. I would use this in your /etc/profile:

/sbin/stty erase "^H" kill "^U" intr "^C" eof "^D" -parity ixoff

To answer the question about changing stty and then changing back, the man page for stty has the answer: stty -g

Use it like this:

OLD_STTY=$(stty -g)
stty


...various tasks...

stty $OLD_STTY




Bill Hassell, sysadmin
Shahril M
Frequent Advisor

Re: login prompt Qn #1

Hi Bill,

I am afraid your previous post either repeated what I learnt from your earlier posts or what I already know from other sources.

And my question remains unanswered.

I wrote:
> What I still want to know is, how do I inspect the current
> default settings so that I know what to revert to if I wish
> to undo my command.
Your answer:
stty -a

This is wrong as you have mentioned yourself, this command (on its own) is not related to "control login behaviour"

In any case, I tried your -g solution -> it does not work in reverting login behaviour.


Rgds,
Shahril
Bill Hassell
Honored Contributor

Re: login prompt Qn #1

Sorry I wasn't looking carefully at the questions. login is very different from a shell prompt. When login runs, it inherits the default settings of the datacomm/telnet driver. There isn't an easy way to see these settings because shell startup profiles change the settings. I don't know of a way to see these settings outside of the shell because stty requires an open terminal device to be associated with the stty command.

However, as I mentioned in the earlier posting, you can change the default settings with the /dev/ttyconf device file. So to change the setting for logins so that @ becomes the kill character (see man termio):

stty kill @ > /dev/ttyconf

This technique depends on somewhat recent patches for networking and datacomm drivers.


Bill Hassell, sysadmin
Shahril M
Frequent Advisor

Re: login prompt Qn #1

Just in case someone else reads Bill's last post only, this is to correct a typo:

the command should be:
stty kill @ < /dev/ttyconf


Rgds,
Shahril