Development > Scripting and Bash

[SOLVED] Program error

(1/3) > >>

bitsnpcs:
Great info thank you  :)
Here is the chapter 29 version2 from book while loop working with break and continue.
Also here I added in the DELAY2, and also fixed the books indentation errors.
It is all on this in the book until chapter 33.



firenice03:
Cool - Might have to look at that one too..



--- Quote ---Maybe there can be a $DELAY and a new line of $DELAY2 where 2 has a longer duration and then edit the sleep delay on line 28 to $DELAY2 , it might work, to have two different durations allowing for the more text to read on that option,  I'll try it tomorrow, as I am tired for code now.
--- End quote ---


You should be able to as long as the variable is expressed... example
DELAY1=2
DELAY2=5
Then call out each specifically within the code..  ***Looks like you tried and it worked!!


You could also use sleep, which when scripting directly from the command line works well..
Example - but substitute in any commands, I may use a variant to watch interfaces or connected HBA cards where I would repeatedly re-run a command.

--- Code: ---while true
do date
echo " "
sleep 3
done
--- End code ---

This will display the Date and a blank line every 3 seconds

Keep it up!!!  ;D ;D

bitsnpcs:
I added a DELAY2 as I mentioned above and it works correctly, so it is 3 seconds on the options 1 and 3 , and 8 seconds on option 2.
Lines changes #6 and #29, only small but it is the first thought and change in shell script I've made other than for alignments.
Added comment line #6, edited comment line #5
Screenshot Lines #31 onwards as above no changes.

bitsnpcs:
This is the while loop version1 [FIXED] from the book, there is to be a version2 of this one later in the chapter 29 using 'continue' as well. I am tired for code now today, I can see version2 also has the same indentation errors and need the same fix as this version, haven't looked at the rest of it yet.

This one you select a menu option it displays it for 3 seconds,  and then it loops back to program to enter another option.I like it I think it could be made in to some nice programs.  The delay can be adjusted on Line 5 to more seconds.

Maybe there can be a $DELAY and a new line of $DELAY2 where 2 has a longer duration and then edit the sleep delay on line 28 to $DELAY2 , it might work, to have two different durations allowing for the more text to read on that option,  I'll try it tomorrow, as I am tired for code now.







There are 2 errors in the while loop code in the book, I fixed these.Both are indentation errors, these are on lines #9 and #17 they should not be indented like they are in the book, just type it like the screenshots then the program runs correctly.

bitsnpcs:
I had wrote previous the last chapter was #38 , the last Chapter is #36 , I was giving myself more chapters coz I need the practice lol (edited above).

Now I have begun the Chapter 29, I found some more information about it, it says it teaches "looping with while and until"  in Chapter 29, and looking forward for the title, it says "Looping with For" for Chapter 23.
Also the command line found a typo in the book now, on the page 358, line 7 of the example of what a while loop is, it has printed -1e, it should be -le 
I think it is the very first typo I have noticed in this book.

Navigation

[0] Message Index

[#] Next page

Go to full version