You are Here:
Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section



[SOLVED] Program error

Author (Read 15410 times)

0 Members and 1 Guest are viewing this topic.

Re: [SOLVED] Program error
« Reply #15 on: February 19, 2019, 09:16:57 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
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.



« Last Edit: February 19, 2019, 09:21:42 PM by bitsnpcs »
 

Re: [SOLVED] Program error
« Reply #14 on: February 19, 2019, 09:02:20 PM »
 

firenice03

  • Rockin' the FREE World
  • Global Moderator
  • Platinum Level Poster
  • *****
  • 1848
    Posts
  • Reputation: 284
  • Linux Lite Member
    • View Profile

  • CPU: AMD E2//Atom X5//AMD Phenom II X2

  • MEMORY: 4Gb

  • VIDEO CARD: AMD Mullin Radeon R2//Intel//AMD/ATI RS880

  • Kernel: 5.x
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.


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: [Select]
while true
do date
echo " "
sleep 3
done

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

Keep it up!!!  ;D ;D
« Last Edit: February 19, 2019, 09:05:07 PM by firenice03 »
LL4.8 UEFI 64 bit ASUS E402W - AMD E2 (Quad) 1.5Ghz  - 4GB - AMD Mullins Radeon R2
LL5.8 UEFI 64 bit Test UEFI Kangaroo (Mobile Desktop) - Atom X5-Z8500 1.44Ghz - 2GB - Intel HD Graphics
LL4.8 64 bit HP 6005- AMD Phenom II X2 - 8GB - AMD/ATI RS880 (HD4200)
LL3.8 32 bit Dell Inspiron Mini - Atom N270 1.6Ghz - 1GB - Intel Mobile 945GSE Express  -- Shelved
BACK LL5.8 64 bit Dell Optiplex 160 (Thin) - Atom 230 1.6Ghz - 4GB-SiS 771/671 PCIE VGA - Print Server
Running Linux Lite since LL2.2
 

Re: [SOLVED] Program error
« Reply #13 on: February 19, 2019, 08:55:28 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
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.

« Last Edit: February 19, 2019, 09:05:04 PM by bitsnpcs »
 

Re: [SOLVED] Program error
« Reply #12 on: February 19, 2019, 06:07:31 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
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.
« Last Edit: February 19, 2019, 06:24:24 PM by bitsnpcs »
 

Re: [SOLVED] Program error
« Reply #11 on: February 19, 2019, 05:17:19 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
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.
 

Re: [SOLVED] Program error
« Reply #10 on: February 19, 2019, 03:51:34 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
@firenice03
I think you know Linux very well :)
 

Re: [SOLVED] Program error
« Reply #9 on: February 19, 2019, 11:42:51 AM »
 

firenice03

  • Rockin' the FREE World
  • Global Moderator
  • Platinum Level Poster
  • *****
  • 1848
    Posts
  • Reputation: 284
  • Linux Lite Member
    • View Profile

  • CPU: AMD E2//Atom X5//AMD Phenom II X2

  • MEMORY: 4Gb

  • VIDEO CARD: AMD Mullin Radeon R2//Intel//AMD/ATI RS880

  • Kernel: 5.x
@bitsnpcs
Take your time... You're doing great :)
I wish I had the time to fully learn it, more so trial by fire and learn as you go..
I know enough to get into trouble, and hopefully enough to get back out... But can poke around to get what I need...


 8) 8) 8)
LL4.8 UEFI 64 bit ASUS E402W - AMD E2 (Quad) 1.5Ghz  - 4GB - AMD Mullins Radeon R2
LL5.8 UEFI 64 bit Test UEFI Kangaroo (Mobile Desktop) - Atom X5-Z8500 1.44Ghz - 2GB - Intel HD Graphics
LL4.8 64 bit HP 6005- AMD Phenom II X2 - 8GB - AMD/ATI RS880 (HD4200)
LL3.8 32 bit Dell Inspiron Mini - Atom N270 1.6Ghz - 1GB - Intel Mobile 945GSE Express  -- Shelved
BACK LL5.8 64 bit Dell Optiplex 160 (Thin) - Atom 230 1.6Ghz - 4GB-SiS 771/671 PCIE VGA - Print Server
Running Linux Lite since LL2.2
 

Re: [SOLVED] Program error
« Reply #8 on: February 19, 2019, 03:53:34 AM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
@firenice03

 :) Good modifications.

I haven't learned these yet, loops are in the next chapter, I learn from the book etc.

Yes I use Gedit on Linux Lite for learning Python, and also learning Shell Scripting as it is the final part of the command line book (Chapters #24 thru #36[end of the book]), I have just completed chapter #28, I've been on this book for a long time maybe 3 or 4 years lol
 I have just added the template to Gedit in Ubuntu on Saturday, I couldn't add the template in Gnome myself, one of the Ubuntu Moderators showed me how to do it. I also had to ask how to add the template the first time on Linux Lite.

On Linux Lite I have also used Leafpad for editing code of files already on the system, or files in Virtualbox when I used to use it, just a couple of times, I also use Leafpad for lists some times, in the same way I used to use textpad in Windows in the past.

I just try and learn code at home.
At the weekend I heard about womens mentoring programmes, so I began to look if they exist for Linux, I have to learn more about them and see if there are any suitable for me, or whether I need to learn a lot more first before I would be able to join it, as it may begin at too advanced a level for me to be able to learn on it.
« Last Edit: February 19, 2019, 04:52:31 PM by bitsnpcs »
 

Re: [SOLVED] Program error
« Reply #7 on: February 18, 2019, 08:10:03 PM »
 

firenice03

  • Rockin' the FREE World
  • Global Moderator
  • Platinum Level Poster
  • *****
  • 1848
    Posts
  • Reputation: 284
  • Linux Lite Member
    • View Profile

  • CPU: AMD E2//Atom X5//AMD Phenom II X2

  • MEMORY: 4Gb

  • VIDEO CARD: AMD Mullin Radeon R2//Intel//AMD/ATI RS880

  • Kernel: 5.x
@bitsnpcs

So I tweaked it a little, it will run in a loop until 0 = quit or an invalid is chosen.
So you can run each without restarting the script.

Thanks for posting it gave me something to play with LOL

I was wondering what you used to edit - I used Geany on my LL box, I use Atom at work for mostly Ruby (still a newbie to it)..
If you're curious - They both allow you have switch between files in tabs - Atom will show your directory tree, where I have files that reference other files I can switch around and still know where I'm at :)

Here's the modifications.. Minor tweaks (I added some spacing for visual)... All other lines are the same (moved 0 to the bottom so I could think it thru :) )

 

LL4.8 UEFI 64 bit ASUS E402W - AMD E2 (Quad) 1.5Ghz  - 4GB - AMD Mullins Radeon R2
LL5.8 UEFI 64 bit Test UEFI Kangaroo (Mobile Desktop) - Atom X5-Z8500 1.44Ghz - 2GB - Intel HD Graphics
LL4.8 64 bit HP 6005- AMD Phenom II X2 - 8GB - AMD/ATI RS880 (HD4200)
LL3.8 32 bit Dell Inspiron Mini - Atom N270 1.6Ghz - 1GB - Intel Mobile 945GSE Express  -- Shelved
BACK LL5.8 64 bit Dell Optiplex 160 (Thin) - Atom 230 1.6Ghz - 4GB-SiS 771/671 PCIE VGA - Print Server
Running Linux Lite since LL2.2
 

Re: [SOLVED] Program error
« Reply #6 on: February 15, 2019, 06:28:35 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
@firenice03 that would be  8) :)

This is the Gedit template I use - https://gist.github.com/LeoIannacone/71028cc3bce04567d77e

« Last Edit: February 15, 2019, 08:03:08 PM by bitsnpcs »
 

Re: [SOLVED] Program error
« Reply #5 on: February 15, 2019, 06:10:39 PM »
 

firenice03

  • Rockin' the FREE World
  • Global Moderator
  • Platinum Level Poster
  • *****
  • 1848
    Posts
  • Reputation: 284
  • Linux Lite Member
    • View Profile

  • CPU: AMD E2//Atom X5//AMD Phenom II X2

  • MEMORY: 4Gb

  • VIDEO CARD: AMD Mullin Radeon R2//Intel//AMD/ATI RS880

  • Kernel: 5.x
@bitsnpcs cool glad it helped, yeah I might mimic that script of yours :)
LL4.8 UEFI 64 bit ASUS E402W - AMD E2 (Quad) 1.5Ghz  - 4GB - AMD Mullins Radeon R2
LL5.8 UEFI 64 bit Test UEFI Kangaroo (Mobile Desktop) - Atom X5-Z8500 1.44Ghz - 2GB - Intel HD Graphics
LL4.8 64 bit HP 6005- AMD Phenom II X2 - 8GB - AMD/ATI RS880 (HD4200)
LL3.8 32 bit Dell Inspiron Mini - Atom N270 1.6Ghz - 1GB - Intel Mobile 945GSE Express  -- Shelved
BACK LL5.8 64 bit Dell Optiplex 160 (Thin) - Atom 230 1.6Ghz - 4GB-SiS 771/671 PCIE VGA - Print Server
Running Linux Lite since LL2.2
 

Re: [SOLVED] Program error
« Reply #4 on: February 15, 2019, 03:15:08 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
@firenice03 2nd Edit has solved it , thank you  8)

Option 0 screenshot



Option 1, 2, 3 , and a screenshot showing the error message for a number entered outside of the 0-3 options.

« Last Edit: February 15, 2019, 03:28:04 PM by bitsnpcs »
 

Re: [SOLVED] Program error
« Reply #3 on: February 15, 2019, 03:00:43 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
@firenice03 here are the top 14 lines and onwards a bit




Thank You I will give these a try :)
Just looking at edit 2


 

Re: [SOLVED] Program error
« Reply #2 on: February 15, 2019, 11:10:32 AM »
 

firenice03

  • Rockin' the FREE World
  • Global Moderator
  • Platinum Level Poster
  • *****
  • 1848
    Posts
  • Reputation: 284
  • Linux Lite Member
    • View Profile

  • CPU: AMD E2//Atom X5//AMD Phenom II X2

  • MEMORY: 4Gb

  • VIDEO CARD: AMD Mullin Radeon R2//Intel//AMD/ATI RS880

  • Kernel: 5.x
@bitsnpcs
I was playing with the du command in my terminal and could replicate a permissions error - although not the same file as you...
using 'du -sh /home' or 'du -sh /home/*'

What did yield the results without error was 'du -sh ~'
Code: [Select]
du -sh ~
May be worth a try in your script... ??? ...
- Also I'd be curious to the top 14 lines of your script - looks like a nice piece of coding :)

Hope it helps!!!


*** Sorry ~ shows your home directory only.. Missed the need for "others/all users"  got caught up playing LOL ****


***2nd Edit - Although your error is in your own home, perhaps permissions are pooched on your files? See this link  ***
https://askubuntu.com/questions/863042/permission-denied-running-find-command
To make your user owner of the files in your home directory


Good Luck
« Last Edit: February 15, 2019, 11:23:08 AM by firenice03 »
LL4.8 UEFI 64 bit ASUS E402W - AMD E2 (Quad) 1.5Ghz  - 4GB - AMD Mullins Radeon R2
LL5.8 UEFI 64 bit Test UEFI Kangaroo (Mobile Desktop) - Atom X5-Z8500 1.44Ghz - 2GB - Intel HD Graphics
LL4.8 64 bit HP 6005- AMD Phenom II X2 - 8GB - AMD/ATI RS880 (HD4200)
LL3.8 32 bit Dell Inspiron Mini - Atom N270 1.6Ghz - 1GB - Intel Mobile 945GSE Express  -- Shelved
BACK LL5.8 64 bit Dell Optiplex 160 (Thin) - Atom 230 1.6Ghz - 4GB-SiS 771/671 PCIE VGA - Print Server
Running Linux Lite since LL2.2
 

[SOLVED] Program error
« Reply #1 on: February 15, 2019, 05:11:20 AM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • View Profile
    • Try to Grow

  • Kernel: 4.x
Hello,

this is the script -



this is the error message on option 3 only





I set the shell script permissions to -

Code: [Select]
chmod 755
As it was what the book specified to use in the first chapter of the shell scripting chapters.

I checked the "18G..." results with error , by changing lines #33 and #36 by adding

Code: [Select]
sudo
the program produces no error, but of course it needs the password to be typed, this confirmed the results of "18G...", as correct. In that the script, as in screenshot above, has the permission denied error but is producing the correct results shown on the next line in the terminal after the error, on the screenshot above.

Options 1, 2, and 0 work without any errors in the program.
The only changes I have made to the script from the book is to beautify the code alignment to my liking.
The error happens before this when run, and still does, so it has not affected the programs functioning.

I would like some help as to how to run this script on option3 without it producing the error.
« Last Edit: February 15, 2019, 03:04:48 PM by bitsnpcs »
 

 

-->
X Close Ad

Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section