- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: korn shell
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2004 06:52 PM
01-01-2004 06:52 PM
Is there any way to trap keys including interrupts ( like ^C,^D etc) though korn shell commands ? . Is so can someone tell me how ?
I expect answers apart from
set trap < command > signal
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2004 07:12 PM
01-01-2004 07:12 PM
Re: korn shell
If you want to assign commands to the keys, you'll be stuck with the trap command.
But if you want to be able to enter those characters, you can do it by using stty and assign other characters to the interrupt and EOF signals:
stty EOF ^? INTR ^?
for instance.
Or you could enter them by first enter a
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2004 09:08 PM
01-01-2004 09:08 PM
Re: korn shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2004 09:19 PM
01-01-2004 09:19 PM
Re: korn shell
Or you could ignore the signals from within the application. And how that can be done depends on the language the application is written in.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2004 03:10 PM
01-02-2004 03:10 PM
Re: korn shell
http://www.ittepic.edu.mx/eBooks/computacion/80oreilly/books/unix2/ksh/ch08_04.htm
http://www.shelldorado.com/goodcoding/tempfiles.html
Mic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2004 08:14 AM
01-03-2004 08:14 AM
Re: korn shell
what you are actually talking about are "signals", in your example produced by the TTY drivers upon certain key-presses.
But there are more signals available than just:
- SIGINT (ususally CTRL-C, ignore it with "trap : 2")
and
- SIGQUIT (ususally something like CTRL-\i, ignore it with "trap : 3"):
Those are:
- in case of serial terminal lines: the BREAK-key (it can generate a SIGINT; turn it off with "stty -brkint")
- SIGHUP (usually sent to all your processes when your shell exits; ignore it with "trap : 1" or "nohup")
- SIGWINCH (sent by your local window manager; ignore it using "trap : " and the number as shown by "kill -l")
To "unset" special keys you'll have to assign an impossible key, like "^@" (which would be the codenumber 0, and cannot be generated by PC-keyboards).
Happy new year,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2004 08:15 AM
01-03-2004 08:15 AM
Re: korn shell
what you are actually talking about are "signals", in your example produced by the TTY drivers upon certain key-presses.
But there are more signals available than just:
- SIGINT (ususally CTRL-C, ignore it with "trap : 2")
and
- SIGQUIT (ususally something like CTRL-\, ignore it with "trap : 3"):
Those are:
- in case of serial terminal lines: the BREAK-key (it can generate a SIGINT; turn it off with "stty -brkint")
- SIGHUP (usually sent to all your processes when your shell exits; ignore it with "trap : 1" or "nohup")
- SIGWINCH (sent by your local window manager; ignore it using "trap : " and the number as shown by "kill -l")
To "unset" special keys you'll have to assign an impossible key, like "^@" (which would be the codenumber 0, and cannot be generated by PC-keyboards).
Happy new year,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2004 08:16 AM
01-03-2004 08:16 AM
Re: korn shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2004 05:20 PM
01-04-2004 05:20 PM
Re: korn shell
Thank you the for your responce. The application that I have is a one hell of long smart korn shell with bit of Tcl/Tk , its basically a menu system that branches into lots of sub-menues and so on , it is designed to handle all the charcters and numbers during the input validation but for any interrupts via ^C,^D or any other combinations I am not able to control them . For instance I do not want the user to exit the program until the program exits himself . But I have already tried set trap option , bit I amo not sure how to ignore them .
set trap "echo Pls You Can Not Log Out Now":0
But this is not going to redo the real action of the interrupt 0 , but it also does the echo message along with the default action of interrupt 0 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2004 06:03 PM
01-04-2004 06:03 PM
SolutionOLDSTTY=`stty -g`
stty intr ^@
stty eof ^@
stty kill ^@
stty -brkint
trap "echo Please let me run" 0 1 2 3 4 5 6 7 8
stty $OLDSTTY
trap "" 0 1 2 3 4 5 6 7 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2004 06:12 PM
01-04-2004 06:12 PM
Re: korn shell
This is cool . I have tried it now , except the echo message that is not getting displayed for instance when I press ^C , else is fine , the signals are getting ignored .
Thank you all