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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 07-01-2009
Starcast Starcast is offline
Registered User
  
 

Join Date: Jan 2009
Location: Minneapolis, MN
Posts: 13
Intercepting SIGINT in a bash script

I've written a bash script which captures video with DVgrab. Because of the nature of the tapes that I am digitizing, sometimes I want to quit capturing before the time that I set for DVgrab. When this is the case I press Ctrl-c and DVgrab exits cleanly, my problem is that there is additional information that the script prints in the terminal with 'echo' when the script runs till it's set time. When I Ctrl-c none of this information prints...

Is there a way to intercept the SIGINT ( I think this is what I want, but I could be wrong) and have it operate exactly as it does by default, but additionally echo a few varibles in the terminal?

Preferably I would like to do this just in my script... and not effect the way Ctrl-c functions system wide.

Not sure if it matters, but based on my reading prior to this post I wasn't sure, but I run this script in a virtual terminal in gnome on an Ubuntu (8.10) Linux machine

The bit that I wanted to add when Ctrl-c is pressed looks like this:

Code:
echo -e "\E[31;40m++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+               Warning - Capture Ended Early                           +"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo -e "\E[30;47m++ Format: $FORMAT    ++ Min Remaing on $destination : $minremain    "
echo "++ Deck: $deck_number          ++ Customer: $customer      " 
echo "++ Rec Time: $tape_length  ++ Tape: $tapename"
Thanks in advance!
-Starcast