LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-12-2008, 03:40 AM   #1
joshiggins
LQ Newbie
 
Registered: Nov 2006
Posts: 25

Rep: Reputation: 15
Bash script stop CTRL+C stopping


Hello

I'm writing a bash script and wondering if there is any way to stop the script terminating when you press CTRL+C. Can it be done?

Thanks in advance
 
Old 06-12-2008, 03:43 AM   #2
joshiggins
LQ Newbie
 
Registered: Nov 2006
Posts: 25

Original Poster
Rep: Reputation: 15
I found the answer http://www.linux.org.za/Lists-Archiv.../msg00916.html

#!/bin/sh

trap "echo 'Trap sprung!'" INT TERM
while 'true'; do sleep 5; done
 
Old 06-12-2008, 03:45 AM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
My bad. I didn't read carefully.

Last edited by bigrigdriver; 06-12-2008 at 03:49 AM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any way to create bash short cuts (like CTRL+l for clear and Ctrl+D for exit) supersubu123 Linux - General 5 05-30-2007 03:02 AM
bash script to read CTRL+D panchosansa Programming 5 10-26-2006 03:25 AM
using cron to start and stop a bash script monty Linux - Software 2 03-20-2006 02:30 PM
Bash script to alert by email 3 times then stop. pmpc00 Linux - General 2 11-04-2004 07:23 AM
bash script to stop isdn service after x mintus? paul.nel Programming 4 03-11-2004 10:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration