Online Expert Day - HPE Data Storage - Live Now
April 24/25 - Online Expert Day - HPE Data Storage - Live Now
Read more
cancel
Showing results for 
Search instead for 
Did you mean: 

run script error

SOLVED
Go to solution
heaman1
Regular Advisor

run script error

if [[ ! $((`date +%d`)) -eq 8 ]]
then
echo test1
else
echo test2
fi


I have a script as above , when I run it , it pop the error below.

08: value too great for base (error token is "08")


Today is 8th , If I change the date to other date , the problem will not happen , can advise what is wrong ? thx
5 REPLIES
Venkatesh BL
Honored Contributor
Solution

Re: run script error

# if [[ ! $((`date +%d`)) -eq 8 ]]
> then
> echo test1
> else
> echo test2
> fi
test2 <<<<

Works for me!

Can you give the output of 'date' command on your machine? What is the OS version?
heaman1
Regular Advisor

Re: run script error

RH Linux

$date
Thu Jan 8 07:00:22 GMT 2009
Dennis Handly
Acclaimed Contributor

Re: run script error

You have been hosed by the Posix Standard where they want to use the junky C convention that 0n is an octal number. You'll either have to use ksh or a string compare:
if [ $(date +%d) != "08" ]; then

Or remove that $(( )), which screams C!
if [ $(date +%d) -ne 8 ]; then

This will duplicate your error:
echo $(( 08 ))
heaman1
Regular Advisor

Re: run script error

thx reply ,

I tried below , it seems works,

if [[ $(date +%d) != "07" ]]


but may I ask why this problem only happens when today is 8th or 9th ? thx
Steven Schweda
Honored Contributor

Re: run script error

> [...] why this problem only happens when
> today is 8th or 9th ?

Because 0-7 are valid octal digits, while 8
and 9 are not? And days not beginning with
"0" are not interpreted as octal numbers?