- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- 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
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-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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2008 08:15 AM
12-04-2008 08:15 AM
Re: Using "Ctrl-C" in Scripting
Sorry in the delay in assigning points as I am trying to check if the provided solutions help. Thanks alot for your help.
Wonder if somebody can help as I am stuck. I trying to do a tusc command for 60 secs before it cntrl-C, but not too sure how to do it. Initially I try the below steps but think it never go to sleep as the tusc command is still running, hence it never cntrl C
tusc
sleep (60)
ctrl-C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2008 08:34 AM
12-04-2008 08:34 AM
Re: Using "Ctrl-C" in Scripting
tusc myprog &
thepid=$!
sleep 60
kill -2 $thepid
If you want attach to the process
tusc -o filresult pid &
thepid=$!
sleep 60
kill -2 $thepid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2008 08:37 AM
12-04-2008 08:37 AM
Re: Using "Ctrl-C" in Scripting
All answers are eligible for points (0-10). Please read:
http://forums11.itrc.hp.com/service/forums/helptips.do?#34
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2009 08:02 PM
01-11-2009 08:02 PM
Re: Using "Ctrl-C" in Scripting
tusc command
sleep 5
kill -QUIT %1