Sponsored Content
Full Discussion: while loop exit
Top Forums Shell Programming and Scripting while loop exit Post 302081907 by tmarikle on Friday 28th of July 2006 05:04:34 PM
Old 07-28-2006
Quick example:

Code:
trap 'break' INT

while :
do
  print $SECONDS
  sleep 2
done

print end

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

csh exit while loop on keystroke

#!/bin/csh I'm using a `while(1)` loop to dispaly real-time information about various files on my system, and I use ^C to exit it when needed. I was hoping there was a way to exit the script on a normal keystroke such as "q". Can someone point me in the right direction? I'm willing to use a... (7 Replies)
Discussion started by: seg
7 Replies

2. Shell Programming and Scripting

Method to exit a for loop

Hi All, Can someone let me know how i can exit a for loop without exiting the script itself .... will the break statement work .... please help .... -Regards (2 Replies)
Discussion started by: Rohini Vijay
2 Replies

3. Shell Programming and Scripting

how to exit a while true loop

Hi guys, I'm new to unix but loving it!! BUT this is driving me nuts as i can't work out the best way to do it. I have a while true loop that i use to monitor something. For my own reasons in ths script i have disabled the CTRL C using the trap command. But i want to put in a option to exit... (5 Replies)
Discussion started by: Noob e
5 Replies

4. Shell Programming and Scripting

exit out of a while loop with error

im running a while loop as a file watcher, with incremental counter on the retries..however when the retries reach it's limit i want it exit and echo and error and stop the batch. Im not sure the code i have will do that already... Here is what i have that works: #!/usr/bin/ksh count=0... (2 Replies)
Discussion started by: sigh2010
2 Replies

5. Shell Programming and Scripting

Exit from loop only when selected

I am trying to get my program to exit when the answer to my question is positive, if I am asking if the answers are correct in the entries that the user inputted and the user says no how do I then have it exit? If they say everything is correct then it continue into the program, I think I am close... (2 Replies)
Discussion started by: gumbi17
2 Replies

6. Shell Programming and Scripting

Exit from loop

hi, how to exit from "if" loop?actually i have mutliple "if" conditions, i have to exit from each "if" loop,if it is true...:confused: Please suggest me... (3 Replies)
Discussion started by: sreelu
3 Replies

7. Shell Programming and Scripting

Loop exit control

Hi I would like to exit the loop below on <Enter> even if it sleeps. Is it possible? while true do my_procedure; sleep 60 done Thanks (7 Replies)
Discussion started by: zam
7 Replies

8. Shell Programming and Scripting

Strange exit of while loop

This code is used to check for duplicate ip and hostnames in an /etc/hosts file CENTRAL is path to /etc/hosts AWK =awk #check CENTRAL for duplicate ips or hostnames# grep -v "^#" $CENTRAL | $AWK '{ print $1, $2; }' | \ while read ip hostname do if... (5 Replies)
Discussion started by: trimike
5 Replies

9. Emergency UNIX and Linux Support

For loop exit

Below for loop not exiting. Can someone help? JBOSS_INST_ARGS=01 02 if ; then for i in $JBOSS_INST_ARGS; do /u/jboss-6.1.0.Final/bin/jboss_init_wise$i.sh start; done (8 Replies)
Discussion started by: vino_hymi
8 Replies

10. UNIX for Beginners Questions & Answers

Using exit in For Loop - Is this acceptable

Hi Folks - Here is a for loop I've created and I just wanted to see if this was okay practice: for M in NAME1 NAME1 NAME3 do echo "Executing MaxL:" $M >>${_LOGFILE} 2>&1 . ${_STARTMAXLPATH}startmaxl.sh ${_MAINPATH}${_MAXLPATH}$M.mxl _RC=$? if then ... (7 Replies)
Discussion started by: SIMMS7400
7 Replies
FAIL(9) 						   BSD Kernel Developer's Manual						   FAIL(9)

NAME
KFAIL_POINT_CODE, KFAIL_POINT_RETURN, KFAIL_POINT_RETURN_VOID, KFAIL_POINT_ERROR, KFAIL_POINT_GOTO, fail_point, DEBUG_FP -- fail points SYNOPSIS
#include <sys/fail.h> KFAIL_POINT_CODE(parent, name, code); KFAIL_POINT_RETURN(parent, name); KFAIL_POINT_RETURN_VOID(parent, name); KFAIL_POINT_ERROR(parent, name, error_var); KFAIL_POINT_GOTO(parent, name, error_var, label); DESCRIPTION
Fail points are used to add code points where errors may be injected in a user controlled fashion. Fail points provide a convenient wrapper around user-provided error injection code, providing a sysctl(9) MIB, and a parser for that MIB that describes how the error injection code should fire. The base fail point macro is KFAIL_POINT_CODE() where parent is a sysctl tree (frequently DEBUG_FP for kernel fail points, but various sub- systems may wish to provide their own fail point trees), and name is the name of the MIB in that tree, and code is the error injection code. The code argument does not require braces, but it is considered good style to use braces for any multi-line code arguments. Inside the code argument, the evaluation of RETURN_VALUE is derived from the return() value set in the sysctl MIB. See SYSCTL VARIABLES below. The remaining KFAIL_POINT_*() macros are wrappers around common error injection paths: KFAIL_POINT_RETURN(parent, name) is the equivalent of KFAIL_POINT_CODE(..., return RETURN_VALUE) KFAIL_POINT_RETURN_VOID(parent, name) is the equivalent of KFAIL_POINT_CODE(..., return) KFAIL_POINT_ERROR(parent, name, error_var) is the equivalent of KFAIL_POINT_CODE(..., error_var = RETURN_VALUE) KFAIL_POINT_GOTO(parent, name, error_var, label) is the equivalent of KFAIL_POINT_CODE(..., { error_var = RETURN_VALUE; goto label;}) SYSCTL VARIABLES
The KFAIL_POINT_*() macros add sysctl MIBs where specified. Many base kernel MIBs can be found in the debug.fail_point tree (referenced in code by DEBUG_FP). The sysctl variable may be set using the following grammar: <fail_point> :: <term> ( "->" <term> )* <term> :: ( (<float> "%") | (<integer> "*" ) )* <type> [ "(" <integer> ")" ] [ "[pid " <integer> "]" ] <float> :: <integer> [ "." <integer> ] | "." <integer> <type> :: "off" | "return" | "sleep" | "panic" | "break" | "print" The <type> argument specifies which action to take: off Take no action (does not trigger fail point code) return Trigger fail point code with specified argument sleep Sleep the specified number of milliseconds panic Panic break Break into the debugger, or trap if there is no debugger support print Print that the fail point executed The <float>% and <integer>* modifiers prior to <type> control when <type> is executed. The <float>% form (e.g. "1.2%") can be used to spec- ify a probability that <type> will execute. The <integer>* form (e.g. "5*") can be used to specify the number of times <type> should be exe- cuted before this <term> is disabled. Only the last probability and the last count are used if multiple are specified, i.e. "1.2%2%" is the same as "2%". When both a probability and a count are specified, the probability is evaluated before the count, i.e. "2%5*" means "2% of the time, but only 5 times total". The operator -> can be used to express cascading terms. If you specify <term1>-><term2>, it means that if <term1> does not 'execute', <term2> is evaluated. For the purpose of this operator, the return() and print() operators are the only types that cascade. A return() term only cascades if the code executes, and a print() term only cascades when passed a non-zero argument. A pid can optionally be specified. The fail point term is only executed when invoked by a process with a matching p_pid. EXAMPLES
sysctl debug.fail_point.foobar="2.1%return(5)" 21/1000ths of the time, execute code with RETURN_VALUE set to 5. sysctl debug.fail_point.foobar="2%return(5)->5%return(22)" 2/100ths of the time, execute code with RETURN_VALUE set to 5. If that does not happen, 5% of the time execute code with RETURN_VALUE set to 22. sysctl debug.fail_point.foobar="5*return(5)->0.1%return(22)" For 5 times, return 5. After that, 1/1000th of the time, return 22. sysctl debug.fail_point.foobar="0.1%5*return(5)" Return 5 for 1 in 1000 executions, but only 5 times total. sysctl debug.fail_point.foobar="1%*sleep(50)" 1/100th of the time, sleep 50ms. sysctl debug.fail_point.foobar="1*return(5)[pid 1234]" Return 5 once, when pid 1234 executes the fail point. AUTHORS
This manual page was written by Zach Loafman <zml@FreeBSD.org>. CAVEATS
It is easy to shoot yourself in the foot by setting fail points too aggressively or setting too many in combination. For example, forcing malloc() to fail consistently is potentially harmful to uptime. The sleep() sysctl setting may not be appropriate in all situations. Currently, fail_point_eval() does not verify whether the context is appropriate for calling msleep(). BSD
May 10, 2009 BSD
All times are GMT -4. The time now is 02:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy