The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Ctrl-M at end of each line navi Shell Programming and Scripting 3 06-04-2008 03:09 AM
how to enable Ctrl + C in ksh dradhzn Shell Programming and Scripting 0 05-01-2006 10:32 PM
Disable ctrl-c,ctrl-d,ctrl-d in ksh script wtofu AIX 6 06-29-2005 04:41 PM
my ctrl+c doesn't work yankee428 UNIX for Dummies Questions & Answers 3 06-02-2005 01:35 PM
Script ctrl+c newtounix UNIX for Dummies Questions & Answers 1 03-19-2001 05:23 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-02-2006
sendhilmani123 sendhilmani123 is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 33
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
  #2 (permalink)  
Old 05-02-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Read about trap in man bash/ksh. And then search this forum with the keywords 'trap signal'
  #3 (permalink)  
Old 05-02-2006
x96riley3 x96riley3 is offline
Registered User
  
 

Join Date: Mar 2006
Location: Nashville
Posts: 79
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0