![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ctrl-M at end of each line | navi | Shell Programming and Scripting | 3 | 06-04-2008 12:09 AM |
| how to enable Ctrl + C in ksh | dradhzn | Shell Programming and Scripting | 0 | 05-01-2006 07:32 PM |
| Disable ctrl-c,ctrl-d,ctrl-d in ksh script | wtofu | AIX | 6 | 06-29-2005 01:41 PM |
| my ctrl+c doesn't work | yankee428 | UNIX for Dummies Questions & Answers | 3 | 06-02-2005 10:35 AM |
| Script ctrl+c | newtounix | UNIX for Dummies Questions & Answers | 1 | 03-19-2001 02:23 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Catching ctrl-C or ctrl-D
Hi there,
I'm using HP-UX 11 machine. I am running a script, thats gonna take a long time to execute. When I press ctrl-c to come out of my script, I have to catch that signal(ctrl-c) and display that ctrl-c had been pressed. How can I do it. Thanks in advance |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Read about trap in man bash/ksh. And then search this forum with the keywords 'trap signal'
|
|
#3
|
|||
|
|||
|
I use this trap in one of my install scripts. So if someone hits control -c when my install script is running, it prints that the install was aborted.
USER=$(logname) LOG=/tmp/sample_install.log #Set Trap trap 'print "Install was aborted in the middle of the install by $USER" | tee -a $LOG; exit 1' 1 2 15 Trap based on the signals. I think there is a total of 31 or so. The above line traps for signal 1, 2, and 15. 1 = HUP 2 = INT 15 = TERM *The output of this command may differ slightly with operating systems. PS..Buy the book, "Unix Shells by example" Ellie Quigley -X |
|||
| Google The UNIX and Linux Forums |