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



Shell script returning divide by zero error

Author (Read 11160 times)

0 Members and 3 Guests are viewing this topic.

Re: Shell script returning divide by zero error
« Reply #3 on: March 26, 2017, 04:44:42 PM »
 

Tegid

  • New to Forums
  • *
  • 10
    Posts
  • Reputation: 3
  • Linux Lite Member
    • View Profile

  • CPU: 2x Intel(R) Core(TM) Duo CPU T2250 @ 1.73GHz

  • MEMORY: 2Gb

  • VIDEO CARD: Intel Mobile 945GM/GMS 943/940GML Express Integrated Graphics Controller
Ha, cheers, those pesky assumptions again.
 

Re: Shell script returning divide by zero error
« Reply #2 on: March 26, 2017, 04:27:49 PM »
 

ralphy

  • PayPal Supporter
  • Gold Level Poster
  • *****
  • 741
    Posts
  • Reputation: 117
  • Linux Lite Developer
    • View Profile
'lite-tweaks-super' returning the following error:


:~/$ lite-tweaks-super
/usr/bin/lite-tweaks-super: line 812: ((: PERCENTAGE = 100 * 1 / 0 : division by 0 (error token is "0 ")


The 'while read  line' loop should not in theory at least by the looks execute any iterations if '$TOTAL_LINES' is zero, my scripting is largely POSIX (blame BSD) and not Bash so off the top of my head I'm not entirely sure what is going on here:


## Arrays execution
run_icon=/usr/share/icons/Faenza/actions/32/system-run.png
x=0
for k in "${!ARRAYC
  • }"; do  x=$(( $x + 1 )); done  # Get the total number of selected items in the array


    TOTAL_LINES=$x

    printf '%s \n' "${ARRAYC
  • }"|

    while read  line
        do
            $line     # Execute functions one by one
            if [ $? = 1 ]; then
                zenity --info --title=" Lite Tweaks" --text="Error:\n${line}"
            fi
        let i++
         (( PERCENTAGE = 100 \* ${i} / ${TOTAL_LINES} ))
         echo "$PERCENTAGE"

        if [ "$PERCENTAGE" == "100" ]; then
            echo "#Done"
            sleep 1
        fi

    done| zenity --progress --width=320 --window-icon="$run_icon" --pulsate --no


Looks to me you are calling lite-tweaks-super instead of lite-tweks. Call lite-tweaks instead which is the one that passes all arrays to lite-tweak-super when needed.
https://unlockforus.com

Sorry for seeming stupid and preferring Linux - I just don't know any better.

 

Shell script returning divide by zero error
« Reply #1 on: March 26, 2017, 04:06:21 PM »
 

Tegid

  • New to Forums
  • *
  • 10
    Posts
  • Reputation: 3
  • Linux Lite Member
    • View Profile

  • CPU: 2x Intel(R) Core(TM) Duo CPU T2250 @ 1.73GHz

  • MEMORY: 2Gb

  • VIDEO CARD: Intel Mobile 945GM/GMS 943/940GML Express Integrated Graphics Controller
'lite-tweaks-super' returning the following error:


Code: [Select]
:~/$ lite-tweaks-super
/usr/bin/lite-tweaks-super: line 812: ((: PERCENTAGE = 100 * 1 / 0 : division by 0 (error token is "0 ")

The 'while read  line' loop should not in theory at least by the looks execute any iterations if '$TOTAL_LINES' is zero, my scripting is largely POSIX (blame BSD) and not Bash so off the top of my head I'm not entirely sure what is going on here:


Code: [Select]
## Arrays execution
run_icon=/usr/share/icons/Faenza/actions/32/system-run.png
x=0
for k in "${!ARRAYC}"; do  x=$(( $x + 1 )); done  # Get the total number of selected items in the array

    TOTAL_LINES=$x

    printf '%s \n' "${ARRAYC}"|
    while read  line
        do
            $line     # Execute functions one by one
            if [ $? = 1 ]; then
                zenity --info --title=" Lite Tweaks" --text="Error:\n${line}"
            fi
        let i++
         (( PERCENTAGE = 100 \* ${i} / ${TOTAL_LINES} ))
         echo "$PERCENTAGE"

        if [ "$PERCENTAGE" == "100" ]; then
            echo "#Done"
            sleep 1
        fi
« Last Edit: March 27, 2017, 11:13:56 AM by Tegid »
 

 

-->
X Close Ad

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