Sponsored Content
Full Discussion: Else Loop Exiting Early
Top Forums Shell Programming and Scripting Else Loop Exiting Early Post 302177256 by joeyg on Thursday 20th of March 2008 12:59:07 PM
Old 03-20-2008
Question Clarifications..

1) Correct. I want it to run until 8675309 starts. Then on the next check it should go to else.

2) Should I change it to
if [ $UL_FILE_TYPE = TEMP -a $UL_PROCESS -eq 0 ]
That is check the file type first and then check for the process?

3) elif is correct; my misspelling. Thanks for the catch!

In response:
1) I think this is odd as you will have two occurrences of the program then running. You run, catch the condition, wait, and start again "as a sub-process". This 2nd run may have different results at "if" statements. Assuming it too does not get caught by the first loop - thus creating a third instance of the script running - control would be returned to the first run at the "elsif" line. Perhaps rethink the logic to a "do while" or "do until" set of commands?
2) I was not commenting on the order within the if, more the logic that I do not believe the program could ever find your "elsif" logic true and able to be executed. The first if is true (UL -eq 0) meaning the "elsif" would not be exexcuted. The first is false (UL -eq 0) meaning the "elsif" would be analyzed, but how could it be now true? Unless this is all to catch the sub-process I referred to in (1)?
3) Concur that "elsif" should be "elif". My other point is that an "elif" should then have its own "then". "elif" expects a "then", so does the program skip a bunch of logic until it finds your next "then" occurrence?
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash: Exiting while true loop when terminal is not the focus window

I am running an Ubuntu Gutsy laptop with Advanced Compiz fusion options enabled. I am using xdotool to simulate keyboard input in order to rotate through multiple desktops. I am looking for a way to kill a while true loop when the Enter key (or Control+C if it is easier) is pushed when the... (2 Replies)
Discussion started by: acclaypool
2 Replies

2. Shell Programming and Scripting

exiting from a loop

I wonder if someone could help me here. I am trying to find a way of exiting from a loop but not exiting me from the script for example #!/bin/ksh # ************* FUNCTIONS ****************** function1() { #ping test ping $1 2 > /dev/null if ; then ... (13 Replies)
Discussion started by: hcclnoodles
13 Replies

3. UNIX Benchmarks

Early PowerMac G5

Hardware Overview: Model Name: Power Mac G5 Model Identifier: PowerMac7,2 Processor Name: PowerPC 970 (2.2) Processor Speed: 1.8 GHz Number Of CPUs: 2 L2 Cache (per CPU): 512 KB Memory: 1.5 GB Bus Speed: 900 MHz Boot ROM Version:... (0 Replies)
Discussion started by: tnorth
0 Replies

4. UNIX for Advanced & Expert Users

"while read ..." loop exiting after reading only one record

Greeting, The following script completes after reading only one record from the input file that contains many records. I commented out the "ssh" and get what I expect, an echo of all the records in the input.txt file. Is ssh killing the file handle? On the box "uname -a" gives "SunOS... (2 Replies)
Discussion started by: twk
2 Replies

5. Shell Programming and Scripting

Problem in exiting a loop

Hi my code looks like: if test $STEP -le 10 then . . ls -1d AM*-OUT|while read MYDIR do cd $MYDIR ls |tail -n1| while read MYFILE do . . if test -s $MYFILE then sqlldr .... rc=$? if test $rc -ne 0 (3 Replies)
Discussion started by: anijan
3 Replies

6. Shell Programming and Scripting

Loop Forever Script Strangely Exiting

Hi, I have a really simple script which I want to run forever, inside the loop it runs a C application which if it exits should restart. #!/bin/sh while true do ./SCF scf.conf >> scf.log sleep 2 done For some reason the SCF C application coredumps and the script is exiting.... (3 Replies)
Discussion started by: marvinwright
3 Replies

7. Shell Programming and Scripting

Problem exiting a WHILE loop in ksh

Hi I am having a problem exiting a WHILE loop. I am on a Sun server using ksh. I am running a Veritas Cluster Software (High Availablity) command to obtain a group status and grepping the command output for status "G" which means that the filesystem is frozen and therefore not available to... (3 Replies)
Discussion started by: bigbuk
3 Replies

8. Shell Programming and Scripting

While Loop Exiting

We are trying to design a flow so that an ETL job shouldn't start until the previous job completes. The script we have written is while ; do sleep 2; done The loop however exits even when the process is actually running. Why could this be happening? (12 Replies)
Discussion started by: jerome_rajan
12 Replies

9. Shell Programming and Scripting

For loop exiting

Hi , I am processing some files using below shell script the problem for loop exit after processing some files even though it exist.After modifying file.txt and rerunning the script and its running .Any Advise for i in `cat /xx/file.txt |tr -s "," '\n' ` ; do echo $i... (3 Replies)
Discussion started by: mohan705
3 Replies
unifdef(1)						      General Commands Manual							unifdef(1)

NAME
unifdef - Removes #ifdefed lines SYNOPSIS
unifdef [-tlc] [-Dsymbol] [-idsymbol] [-iusymbol] [file] [-Usymbol] The unifdef command partially simulates the behavior of the C preprocessor in processing #ifdef conditionals. OPTIONS
Complements the action of unifdef; retains lines that would normally be removed and removes lines that would normally be retained. Speci- fies symbol as a defined #ifdef symbol. Specifies defined lines inside certain #ifdefs to be ignored but copied out. Specifies undefined lines inside certain #ifdefs to be ignored and not copied out. Replaces removed lines with blank lines instead of deleting them. Pro- cesses plain text (rather than C code) input. The unifdef command does not try to recognize comments, single quotes, and double quotes. Specifies symbol as an undefined #ifdef symbol. DESCRIPTION
The unifdef command recognizes nested #ifdefs, comments, single and double quotes of C syntax so that it can function correctly, but does not include files or interpret macros. The unifdef command recognizes, but does not remove comments. The unifdef command takes its input from stdin if no file argument is given, and copies its output to stdout. You specify the symbols you want defined with -Dsymbol or undefined with -Usymbol and the lines inside those #ifdefs are copied to the out- put or removed, as appropriate. The #ifdef, #ifndef, #else, #elif, and endif lines associated with symbol are also removed. The #ifdefs involving unspecified symbols are untouched and copied out along with their associated #ifdef, #else, elif, and #endif lines. If the same symbol appears in more than one argument, only the first occurrence is significant. For instance, if an #ifdef X occurs nested inside another #ifdef X, the inside #ifdef is considered an unrecognized symbol. If you use #ifdefs to delimit non-C lines, such as comments or unfinished code, it is necessary to specify which symbols are to be used for that purpose. Otherwise, the unifdef command tries to parse for quotes and comments in those #ifdef lines. Keywords The following keywords can be used with the unifdef command: ifdef ifndef else endif elif The unifdef command uses the elif keyword as follows. (Note that "Understood" means unifdef knows how to convert elif to if.) Understood Not understood Not understood For example: # ifdef X x # elif defined (Y) y # elif defined (A) || defined (B) a # else default # endif The following list shows the results of using the elif keyword with variables: -DX x -UX # if defined (Y) y # elif defined (A) || defined (B) a # else default # endif -UX -DY y -UY -UX # if defined (Y) y # elif defined (A) || defined (B) a # else default # endif -UY -UX -DA # if defined (Y) y # elif defined (A) || defined (B) a # else default # endif NOTES
The unifdef command cannot process cpp constructs such as: #if defined(X) || defined(Y) DIAGNOSTICS
The unifdef command can fail for several reasons: a premature end of file, or an inappropriate else, elif, or endif. EXIT STATUS
Exit status is 0 if output is an exact copy of input, 1 if not, 2 if the unifdef command fails. EXAMPLES
The following command line causes the unifdef command to read the file original.c and remove the #ifdef A lines. It then removes every- thing following an #elif/#else associated with the #ifdef A down to the #endif: unifdef -DA original.c > modified.c The following command line causes the unifdef command to read the file original.c, and remove the #ifdef A down to either its associated #elif/#else, or its associated #endif: unifdef -UA original.c > modified.c In the case of the #elif, the #elif is replaced with #if. In the case of #else, the #else is deleted along with its associated #endif. SEE ALSO
Commands: diff(1) unifdef(1)
All times are GMT -4. The time now is 08:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy