- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How do I ignore Ctrl-C in ksh scripts?
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
02-16-2004 03:32 AM
02-16-2004 03:32 AM
Today, not for the first time, one of the DBAs "Ctrl-C"-d out of one of the BCV scripts, thus leaving the BCV in an "inconsistent" state - half-way unmounted and halfway still mounted (if you follow my meaning).
How so I modify a ksh script to IGNORE Ctrl-C? I don't want to "trap" it. I just want to ignore it, and keep right on going from where it is.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 03:41 AM
02-16-2004 03:41 AM
SolutionYou can now cause a SININT to be ignored via the trap statement using a null string command argument.
trap '' 2
Plan B. Use stty to set intr to an impossible value:
stty intr 0377
but be sure to reset to original value later because a stty command applies to the terminal device rather than a process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 05:43 AM
02-16-2004 05:43 AM
Re: How do I ignore Ctrl-C in ksh scripts?
That looks absolutely right to me. I'll give it a try and post points.
Stuart
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 06:00 AM
02-16-2004 06:00 AM
Re: How do I ignore Ctrl-C in ksh scripts?
trap "" 1 2 3
or
trap "" HUP INT QUIT
This will do nothing for CTRL-C, as well as a hang-up (connection break, either modem or network) or kill -3 to create a core dump.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 06:23 AM
02-16-2004 06:23 AM
Re: How do I ignore Ctrl-C in ksh scripts?
# stty -a
...
intr = ^C; quit = ^\; erase = ^H; kill = ^U
eof = ^D; eol = ^@; eol2 = ^@; swtch = ^@
stop = ^S; start = ^Q; susp = ^Z; dsusp = ^@
werase = ^@; lnext = ^@
...
Does this mean that?:
...SIGINT is ^C
...SIGQUIT is ^\
...SIGKILL is ^U
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 06:27 AM
02-16-2004 06:27 AM
Re: How do I ignore Ctrl-C in ksh scripts?
I would go with "trap" myself. Have used it many times and it will do the trick for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 06:28 AM
02-16-2004 06:28 AM
Re: How do I ignore Ctrl-C in ksh scripts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 06:31 AM
02-16-2004 06:31 AM
Re: How do I ignore Ctrl-C in ksh scripts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 06:36 AM
02-16-2004 06:36 AM
Re: How do I ignore Ctrl-C in ksh scripts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 06:38 AM
02-16-2004 06:38 AM
Re: How do I ignore Ctrl-C in ksh scripts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2004 06:40 AM
02-16-2004 06:40 AM
Re: How do I ignore Ctrl-C in ksh scripts?
Stuart