- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell Script: trap
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
11-01-2002 12:02 PM
11-01-2002 12:02 PM
Shell Script: trap
I am testing and find it is possible to break from the mneu to the shell.
I use:
trap 1 2 3 4 6
This is what I have found.
If the user hits Ctl C, it sends a character to screen.
If the user hits Ctl D, they get logged off the system.
If they hit Ctl C, and then they hit Ctl D, they break to
the unix prompt.
Is there another trap number to add?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 12:19 PM
11-01-2002 12:19 PM
Re: Shell Script: trap
In order to ignore signals like ctrl C you need to use:
trap '' 2
That is the action on trap is a null string. Your usage of trap simply resets them to their original values. See man sh-posix for more info.
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 12:20 PM
11-01-2002 12:20 PM
Re: Shell Script: trap
trap 1 2 3 is very different from trap '' 1 2 3. The former says restore the signal handlers to their default vaues while the latter says ignore the signal.
Next, you are making some assumptions about Cntl-C and Cntl-D, etc. that are unwarranted. Who is to say what key (if any) generates a SIGINT. You need to also use stty -a to examine these values. One technique that you can use is to use stty to set the intr and quit keys to impossible values so that they can never generate the signals. If you do this, make ceratin that you restore the stty settings to their originals on exit because stty changes affect all processes connected to that tty (or pty port) - not just the current process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 12:30 PM
11-01-2002 12:30 PM
Re: Shell Script: trap
I use:
trap " " 1 2 3 4 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 12:32 PM
11-01-2002 12:32 PM
Re: Shell Script: trap
You MUST have a null string, either two quotes "" or two apostrophes ''.
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 12:33 PM
11-01-2002 12:33 PM
Re: Shell Script: trap
Depending on what your script is doing, and how the script is to be used. You might be able to create a wrapper script, that calls your menu script.
#!/usr/sbin/ksh
/home/my_script
exit