The UNIX and Linux Forums  

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
how to exit a while true loop Noob e Shell Programming and Scripting 5 08-26-2007 03:44 PM
Method to exit a for loop Rohini Vijay Shell Programming and Scripting 2 11-01-2006 05:56 AM
Need Clean Exit from KSH Status Loop ScottKe Shell Programming and Scripting 2 08-30-2006 05:53 PM
csh exit while loop on keystroke seg Shell Programming and Scripting 7 12-29-2004 11:45 AM
Where can I find a list of exit codes? (Exit code 64) jkuchar747 UNIX for Dummies Questions & Answers 3 12-07-2004 06:08 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-28-2006
Terrible
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
while loop exit

i wrote a while script as part of a huge program. this script, once picked, begins to output data to the person using it. pretty easy, as the person doesn't have to keep typing commands to get the output that the while loop automatically throws out.

now, the thing is, while this while-script is outputing data the only way for the client to exit out of the script is to Control-C out of it. and when they do, that Control-C not only kicks em out the while-script, it also kicks em out of the program that the while-script is in there by causing the client to have to restart the program?

is there anything i can add to this while-script that will give the user the option to exit out of it without havint to control-c?
  #2 (permalink)  
Old 07-28-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
You can trap the interrupt signal

trap 'somefunction' INT
  #3 (permalink)  
Old 07-28-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
Quick example:


Code:
trap 'break' INT

while :
do
  print $SECONDS
  sleep 2
done

print end

  #4 (permalink)  
Old 07-28-2006
Terrible
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
i tried this but it didn't seem to work. problem is i have more than one while loop in this script. all i'm trying to do is that when a user enters control-c and then hits x, then the user should be directed to the main menu of the program. instead, they get exited out of the script.

i dont know if theres a way for a user to, while the while-script is running, be able to enter any letter and have that letter server as a signal for while to stop looping
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 06:18 AM.


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