- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Trapping Ctrl C signal...
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
04-22-2004 12:00 AM
04-22-2004 12:00 AM
Trapping Ctrl C signal...
I have a scenario whereby there are 2 scripts- script A and B.
Script A calls B. Both script A as well as B have the inbuilt traps i.e. trap "" 2 3 15 .Script B has commands like swlist, swinstall etc.
I invoke script A. It calls script B and when the execution is going on in script B, I invoke Ctrl +C and it gives me following messages:
WARNING: Exiting due to keyboard interrupt.
WARNING: Exiting due to keyboard interrupt.
/abc/xyz/pankaj[47]: test: Specify a parameter with this command.
Same thing does not happen in case execution is continuing in script A. Does anyone have a clue as to why the trap for Ctrl + C is not working in script B. Is it something to do with swinstall, swlist commands? If yes, then what is the workaround for the same?
Also if I continously press Ctrl + C then WARNING message keeps on popping and normal functioning of script B is hampered.
Thanx for your responses in advance...
Regards,
Pankaj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 12:12 AM
04-22-2004 12:12 AM
Re: Trapping Ctrl C signal...
ksh provide the trap function to deal with signal.
Exemple :
#!/bin/ksh
gotcha() {
echo 'Noticed you wanted to exit shell'
echo 'cleaning stuff and leaving'
exit 0
}
trap "gotcha" 2
sleep 10
exit 0
Cheers
Nicolas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 12:17 AM
04-22-2004 12:17 AM
Re: Trapping Ctrl C signal...
/abc/xyz/pankaj[47]: test: Specify a parameter with this command
However, if "swlist" et al redefine the action to take on SIGINT which they probably do, there isn't much you can do about it really. I would be surprised if the "swlist" program didn't redefine SIGINT becuase most people don't run it from a script taht traps SIGINT itself.
Maybe try the other approach, i.e. redefining the interrupt key to something bizarre using "stty" for the duration of the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 03:32 PM
04-22-2004 03:32 PM
Re: Trapping Ctrl C signal...
Thanx for the solutions.
The script error is not having an error as without the interrupt signal it works fine.
Also how to redefine using "stty"??? Will it work if swlist is already handling the interrupt signal???
Any other solution for the scenario...
Regards,
Pankaj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 05:08 PM
04-22-2004 05:08 PM
Re: Trapping Ctrl C signal...
However, swlist/swinstall etc. have their own INT signal trapping, and that's getting past your script's trap.
Because the INT is breaking out of whatever the swlist etc. are doing, and you're expecting a result to be thrown into a VAR (it seems), the VAR is empty, thus causing the error on line 47.
Possibly need to do some error checking prior to doing the needed test on line 47 (i.e. see if the output of the swlist that you're capturing actually has anything in it).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2004 05:15 PM
04-22-2004 05:15 PM
Re: Trapping Ctrl C signal...
stty intr ^@
It is important to note that the "^@" here is not the CTRL and @ key together. It is the ^ and then the @