'true' returns nothing successfully, while false returns nothing unsuccessfully. As a result, using 'while false' would only exit your loop rather quickly, while not executing the code beneath. 'while' and 'while true' vary in what the condition is for the loop. If nothing is passed to 'while' then it assumes 'while true'.
That shows the exit code of "true" and "false". As you can see, they both do nothing. One returns a passing exit code, while the other returns a failing exit code. The "while" function wants an argument. It will continue parsing code inside the loop until the argument fails.
This piece of code will open four xterm windows. It will only open four, because we set our variable 'i' to 0 and increment it once per loop iteration. When it reaches the value of four, the while condition fails, and the code block will no longer be executed.
So, because "true" does nothing successfully, if you had "while true" in that code block, it would continue and continue to open xterm windows until you ran out of physical resources, and the box could no longer function.
Because "false" does nothing unsuccessfully, if you had "while false" in that code block, it would not even initialize the loop, and immediately exit without opening a single xterm window.
I have a script script.shwhich is scheduled to run at 11 AM everyday.
# script.sh Code:
unfortunately scb_script.sh is running today in infinite loop as respective files are not available.
My question, when script.sh starts running tomorrow, will the old process be... (1 Reply)
Im unable to stop the below infinite loop (bash script). Can someone tell me why this isnt responding to signals eg: ctrl+c (SIGINT) or ctrl+z
echo "count value is : $c "
Im using: SunOS 5.10
PS: If run this as... (13 Replies)
Hi, I was debating if I should put this in the dummies or scripts section, I apologize in advance if I chose poorly.
Fairly new to Unix and BASH scripting but I thought I made it fairly well given my limited understanding. However, the output indicates that it's looping and I'm ending up with a... (5 Replies)
1. The problem statement, all variables and given/known data:
My problem is an infinite loop when i press any other key other then Y or y in the while loop. what i want it to do is return to the normal script outside of it if pressing N or n or keep asking the same question if its any other... (4 Replies)
I need to run an infinite loop.
function1 --> creates a file file1
function2 ---> need to call if the file creates
i am running these both function via a script --> script.sh
i need to run the function1 first and if the file file1 creates then need to run the... (3 Replies)
I wanted to copy (not forward but copy) all incoming email to another address of mine. It worked, but now I encountered an infinite loop problem: When the second address doesn't like the content and bounces the message back, the bounce message will be sent back and forth.
So, what I have in... (1 Reply)
this is how my scrip looks like
while : ; do
ls -1rt /opt/apps/script/data/check.txt*|tail -1 > /dev/null 2>&1
chmod +rwx $bindir/dummy2.sh
... (8 Replies)
Production C code compiled without the dash-g option is running, and seems to be in an infinite loop. Is there a way to tell? Is there a diagnostic tool that will report what objects or what lines of code or even what functions are being executed?
Or is my best option to kill it with a dump?
... (5 Replies)
Hi guys, I'm having a problem getting my infinite loop to loop. It simply reads in the users choice form the menu, executes the corresponding case statement and quits instead of looping back to the main menu again. I have a feeling it might be something with my if then statements within the case... (2 Replies)
whenever I am giving a 'ls' command system is going into infinite loop displaying the current home directory.
There is no separate shell script/file with ls name anywhere in the system.
I am using Solaris 10.
Any help / guidance in solving this problem is highly appreciated.
... (3 Replies)