- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Can't use CTRL-C to exit a script
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
08-11-2003 12:08 AM
08-11-2003 12:08 AM
TIA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2003 12:11 AM
08-11-2003 12:11 AM
Re: Can't use CTRL-C to exit a script
trap "" 2
to the script.
For extra protection (from hangup and quit signals)
use trap "" 1 2 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2003 12:19 AM
08-11-2003 12:19 AM
Re: Can't use CTRL-C to exit a script
stty intr ^-
this will change the interrupt routine to undefined.
Roland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2003 12:23 AM
08-11-2003 12:23 AM
Re: Can't use CTRL-C to exit a script
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2003 12:24 AM
08-11-2003 12:24 AM
Re: Can't use CTRL-C to exit a script
again, thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2003 12:27 AM
08-11-2003 12:27 AM
Re: Can't use CTRL-C to exit a script
PLEASE, do not waht I suggest before.
It switched off the interrupted routine for the shell you have in wihich you start the script, too. So do that in your script:
trap "" 2
Roland
(NO POINTS ,PLEASE)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2003 01:02 AM
08-11-2003 01:02 AM
SolutionThe command won't disable CTRL+D, although this shouldn't matter as the user is in a script, and CTRL+D is normally an exit from a shell.
The hangup and quit signals,(from man kill);
1 SIGHUP Hangup Terminate; can be trapped
2 SIGINT Interrupt Terminate; can be trapped
3 SIGQUIT Quit Terminate with core dump; can be trapped
The Quit signal can be triggered manually using CTRL+\ (another potential way for users to exit the script).
The hangup is more normally sent directly via the kill command (kill -HUP PID)
If you use kill -l (that's a lower case L), it will list all signals that can be sent from the kill command, most of which can be trapped if necessary. More details can be seen in the man pages using
man 5 signal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2003 01:10 AM
08-11-2003 01:10 AM
Re: Can't use CTRL-C to exit a script
again, thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2003 01:17 AM
08-11-2003 01:17 AM
Re: Can't use CTRL-C to exit a script
trap - 2, then call your shell.
The - sets the trap for whichever signals you list after it back to their default values.
Chris