Home » Infrastructure » Unix » Urgent
Urgent [message #98248] Thu, 27 May 2004 20:37 Go to next message
pulkit
Messages: 18
Registered: April 2004
Junior Member
HI

I want to trap delete key and replace its functionality to exit.

How can i do this?

Regards

Pulkit

 

 

 

 

 
Re: Urgent [message #98249 is a reply to message #98248] Fri, 28 May 2004 09:12 Go to previous messageGo to next message
Tak Tang
Messages: 142
Registered: May 2004
Senior Member
I think you need to use the 'stty' command.

To prevent CTRL-C from sending an INTR :-

stty intr ""

Takmeister
Re: Urgent [message #98255 is a reply to message #98249] Sun, 30 May 2004 19:22 Go to previous messageGo to next message
pulkit
Messages: 18
Registered: April 2004
Junior Member
HI,

Thanks a lot for sending me the solution.

Please do me one more favor if possible please send me the complete code for it in unix Shell scripting.

regards
Pulkit
Re: Urgent [message #98257 is a reply to message #98255] Tue, 01 June 2004 04:33 Go to previous messageGo to next message
Tak Tang
Messages: 142
Registered: May 2004
Senior Member
Do 'man stty' for complete details.

You can get a list of you current bindings with 'stty -a'.

$ stty -a
speed 9600 baud; line = 0;
rows = 24; columns = 80
min = 4; time = 0;
intr = ^C; quit = ^; erase = DEL; kill = ^U
eof = ^D; eol = ^@; eol2 <undef>; swtch <undef>
stop = ^S; start = ^Q; susp = ^Z; dsusp <undef>
werase <undef>; lnext <undef>
parenb -parodd cs7 -cstopb hupcl -cread -clocal -loblk -crts
-ignbrk brkint ignpar -parmrk -inpck istrip -inlcr -igncr icrnl -iuclc
ixon -ixany ixoff -imaxbel -rtsxoff -ctsxon -ienqak
isig icanon -iexten -xcase echo echoe echok -echonl -noflsh
-echoctl -echoprt -echoke -flusho -pendin
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel -tostop

You can see that on my machine, the DEL key erases characters; Control-C sends an interrupt signal; Control- sends a quit signal; and Control-U kills the current active process.

You can redefine a key binding like this :-

$ stty kill ^P

$ stty
speed 9600 baud; evenp hupcl cread
intr = ^C; erase = DEL; kill = ^P;
swtch <undef>;
susp = ^Z;
brkint -inpck icrnl -ixany ixoff onlcr
-iexten echo echoe echok
-echoctl -echoke

You can 'undefine' a key binding like this :-

$ stty kill ^-
$ stty
speed 9600 baud; evenp hupcl cread
intr = ^C; erase = DEL; kill <undef>;
swtch <undef>;
susp = ^Z;
brkint -inpck icrnl -ixany ixoff onlcr
-iexten echo echoe echok
-echoctl -echoke
Re: Urgent [message #98258 is a reply to message #98255] Tue, 01 June 2004 07:25 Go to previous message
Tak Tang
Messages: 142
Registered: May 2004
Senior Member
'stty' will list the current bindings.

$ stty
speed 9600 baud; evenp hupcl cread
intr = ^C; erase = DEL; kill = ^U;
swtch <undef>;
susp = ^Z;
brkint -inpck icrnl -ixany ixoff onlcr
-iexten echo echoe echok
-echoctl -echoke

You can see that Control-C sends an 'intr' signal, and Control-U sends a 'kill' signal. I suspect your 'kill' signal is mapped to 'DEL'.

I can change them like this :-

$ stty kill ^W
$ stty
speed 9600 baud; evenp hupcl cread
intr = ^C; erase = DEL; kill = ^W;
swtch <undef>;
susp = ^Z;
brkint -inpck icrnl -ixany ixoff onlcr
-iexten echo echoe echok
-echoctl -echoke

or I can undefine it like this :-

$ stty kill ^-
$ stty
speed 9600 baud; evenp hupcl cread
intr = ^C; erase = DEL; kill <undef>;
swtch <undef>;
susp = ^Z;
brkint -inpck icrnl -ixany ixoff onlcr
-iexten echo echoe echok
-echoctl -echoke

Do 'man stty' for more information.

If you want to set it for your own sessions, modify your '~/.profile'.

Takmeister
Previous Topic: Sed or Java
Next Topic: Subject parameter in sendmail
Goto Forum:
  


Current Time: Fri Apr 19 23:29:28 CDT 2024