Current Position:Home > Bash script aid - 'value too great for base' error

Bash script aid - 'value too great for base' error

Update:11-30Source: network consolidation
The error is:
/home/scripts/others/polysleep: line 15: 60 - ((((((08: value too great for base (error
token is "08")
Here's the script (it's an alarm for naps of different lengths) :
if [ $UID != "0" ]; then
echo "You must run this script as root." 1>&2
TIME_SET=`date +%M`
while [ "1" -lt "2" ]
DATE=`date +%k:%M:%S`
MINUTE=`date +%M`
// The offending line:
REMAINING=$(($DELAY - (((((($MINUTE + 60)) - $TIME_SET)) % 60))))
// I want it to show how long is left before the time is up (ie. it subtracts the time that has
// passed from the $DELAY that was set). Since it's in minutes, I need to do the arithmetic
// in modulo 60 (the '% 60' bit) - I tried this initially without the '+ 60' above, but got the
// same error as I've posted, and thought that initially plus-ing 60 to $MINUTE (the
// minute section of 'date' at the current time) would solve it. Apparently that hasn't
// worked though =o(
echo "1. I'm awake"
echo "2. I'm going for a nap"
echo "3. I'm going out"
echo Current Time: $DATE
echo Time Remaining: $REMAINING minutes
read -t 1 -e input
if [ "$REMAINING" = "0" ]
play -v .15 /home/.sounds/alarm.mp3&
TIME_SET=`date +%M`
if [ "$input" = "1" ]
TIME_SET=`date +%M`
elif [ "$input" = "2" ]
TIME_SET=`date +%M`
die centericq
elif [ "$input" = "3" ]
TIME_SET=`date +%M`
I'd be grateful for advice, since apart from that error popping up after some time has passed, the script runs flawlessly.

The Best Answer

Komodo wrote:
This is from … 2/044.html , and explains it better than I could:
"bash allows you to perform arithmetic expressions. As you have already seen, arithmetic is performed using the expr command. However, this, like the true command, is considered to be slow. The reason is that in order to run true and expr, the shell has to start them up. A better way is to use a built in shell feature which is quicker. So an alternative to true, as we have also seen, is the ":" command. An alternative to using expr, is to enclose the arithmetic operation inside $((...)). This is different from $(...)."
Yeah, I knew that already. But what I meant were the extra paranthesis you're using. This is the calculation the way you do it:
REMAINING=$(($DELAY - (((((($MINUTE + 60)) - $TIME_SET)) % 60))))
But this is totally adequate:
REMAINING=$(( $DELAY - (( $MINUTE + 60 ) - $TIME_SET ) % 60 ))
Notice the 6 vs. 2 brackets in front of $MINUTE?
  • Bash script aid - 'value too great for base' error Update:11-30

    The error is: /home/scripts/others/polysleep: line 15: 60 - ((((((08: value too great for base (error token is "08") Here's the script (it's an alarm for naps of different lengths) : #!/bin/bash if [ $UID != "0" ]; then echo "You

  • [solved] help with a bash script Update:11-30

    I'm trying to write a bash script to add Replay Gain to my FLAC collection, and I think I've hit a wall with a seemingly simple bash task. You don't need to know anything about Replay Gain or FLAC to help me, just a working knowledge of bash scriptin

  • [SOLVED] silently execute bash script after key press Update:11-30

    I am attempting to map the brightness keys ( F4 and F5 ) to a bash script I wrote to change the brightness on a Dell XPS 13. The issue is that I don't want the key map to display the bash command to the console when I press it. The method outlined in

  • Sending email using bash script Update:10-11

    Hello: I am working on writing a bash script to notify one or more users by email of certain events. Run from the Terminal command line, and having the script "echo" text of (what would be) a form letter with in-line variable expansion (i.e., ${

  • [SOLVED] problem with spaces and ls command in bash script Update:10-11

    I am going mad with a bash script I am trying to finish. The ls command is driving me mad with spaces in path names. This is the portion of my script that is giving me trouble: HOMEDIR="/home/panos/Web Site" for file in $(find "$HOMEDIR&quo

  • Can't get conky-cli and bash scripts to both display in dwm statusbar! Update:10-11

    I'm trying to configure my dwm status bar to display some simple information using conky-cli and bash scripts. At first I tried just letting conky run the bash scripts (for network and volume state), but this increased my cpu usage by about 5%, which

  • What do you think of my Bash Script? What about the error checking? Update:10-11

    Well what do you think of this Bash script It works I gave it some problems (i.e. unpluged the ethernet, messed up the URL's, uninstaled some programs...) to see if would report errors and stop or just keep going... But it did I just kind of thought

  • /etc/rc.d/network: bash script: how to find out, if there was an error Update:10-11

    hello! i want to write a bash script for my wireless lan. for this i need the information, if the network daemon has connected successfully or failed. but there is a big problem: starting network success' every time, whether there was an error or not

  • Using Bash script to edit config file Update:10-11

    This is a really simple question, but given that I'm just learning Bash scripting and having this solved now would be really illustrative for me, I would really thank some help here. I'm using uzbl, and running Tor+Polipo. So, as you will see below i


    HI. Here's a tricky little problem i have. There's a unix bash script that has some commands in it, that manipulate a file. It appends a certain string variable to a file called users. The users file is an ordinary text file. I know this script to wo