- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Using "Ctrl-C" in Scripting
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
Discussions
Discussions
Forums
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
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-26-2008 11:27 PM
тАО11-26-2008 11:27 PM
It required in the script to break out from certain processes.
Thanks alot for your help~
Solved! Go to Solution.
- Tags:
- SIGINT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-26-2008 11:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-26-2008 11:41 PM
тАО11-26-2008 11:41 PM
Re: Using "Ctrl-C" in Scripting
If you want to send a control-C to another process you can use:
kill -INTR PID
- Tags:
- trap
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-26-2008 11:46 PM
тАО11-26-2008 11:46 PM
Re: Using "Ctrl-C" in Scripting
Please use the trap command in your script
trap "exit" 2
This exit the script whenever it receives a
Ctlr C
Sagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2008 12:07 AM
тАО11-27-2008 12:07 AM
Re: Using "Ctrl-C" in Scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2008 02:14 AM
тАО11-27-2008 02:14 AM
Re: Using "Ctrl-C" in Scripting
myproc1 &
firstpid=$!
myproc2 &
secondpid=$!
myproc3 &
thirdpid=$!
trap "kill -SIGINT $secondpid" 2
Then if you CtrlC it will kill only myproc2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2008 07:18 AM
тАО11-27-2008 07:18 AM
Re: Using "Ctrl-C" in Scripting
You can change what the trap does, too. You might want to disable the Ctrl_C interrupt (INT) in a critical region of your script's code and then change it to "normal" behavior. For example:
# cat ./myctrl_c
#!/usr/bin/sh
function paint
{
typeset -i n
while (( n < 9 ))
do
echo $1
(( n=n+1 ))
sleep 1
done
}
trap 'echo That was not allowed!' INT
paint "+"
echo "...try interrupting now"
trap 'echo CTRL_C sensed;exit' INT
paint "-"
exit 0
See the 'sh-posix' manpages for more information, too.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2008 11:12 PM
тАО12-01-2008 11:12 PM
Re: Using "Ctrl-C" in Scripting
1 more thing, how do we actually do a 60sec wait state?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2008 11:25 PM
тАО12-01-2008 11:25 PM
Re: Using "Ctrl-C" in Scripting
sleep 60
This will wait for 60 seconds
Sagar
- Tags:
- sleep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-03-2008 09:49 PM
тАО12-03-2008 09:49 PM
Re: Using "Ctrl-C" in Scripting
Please assign points if you have got the answers you needed
Sagar