Register
It is currently Tue Jul 29, 2014 10:47 am

Error when running script: value too great for base


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Wed Jan 13, 2010 2:31 pm   

Joined: Mon Jan 04, 2010 7:26 pm
Posts: 8
Okay, ran into a bit of a snag. The script worked great until the other day. Then I started getting the following error:

Code:
line 53: 2010-01-08: value too great for base (error token is "08")


Line 53 is part of the following:
Code:
   50  # The for(1) loop will read the $file and sort it according to column 1, the date in your supplied example.
    51  for i in $MYFILE; do
    52     # This adds the second column to an array named "array1"
    53     array1[$i]=$(echo $i | cut -d',' -f2)
    54     # This adds the third column to an array named "array2"
    55     array2[$i]=$(echo $i | cut -d',' -f3)
    56     # Increment the elemental counter :)
    57     ((i++))
    58  done
    59  IFS=$old_IFS


I get the feeling that it is because the 08 in the date is being interpreted as an octal. I can't change the way the date is being stored, as it is an enterprise application I don't control the configuration of. Is there a way I can get the script to interpret the number as base-10 instead?

A


Top
 Profile  
 PostPosted: Wed Jun 22, 2011 3:53 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
« August is the month when all your scripts break because you placed $(date +%m) in a variable and tried to do arithmetic with it, without removing the leading zeros. 08 is considered octal. Use $((10#$month)) to force decimal, or strip the zero. » #bash

;-)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP