Re: AIX 5.2 vs 4.3.3 differences

From: Green, Simon (Simon.Green@EU.ALTRIA.COM)
Date: Fri Jun 13 2003 - 12:15:34 EDT


First option would be to get the date in the correct format to start with,
(date +%Y%m%d).

Second, option:
typeset -Z -L date=030611
That will strip leading zeros, so it'll be treated correctly as a decimal
number.

Third option, just put 20 in front of it: date=20${date}.

I've confirmed the same behaviour on a 5.1 box, (ML04). It actually throws
errors up if you have an "invalid" number, such as 030618, (obviously there
can't be an 8 in an octal number). So you better fix it before Wednesday!

I haven't bothered to search for an APAR for this so you might like to do
that.

Simon Green
Altria ITSC Europe s.a.r.l.

AIX-L Archive at http://marc.theaimsgroup.com/?l=aix-l
<http://marc.theaimsgroup.com/?l=aix-l&r=1&w=2> &r=1&w=2
AIX FAQ at http://www.faqs.org/faqs/aix-faq/
<http://www.faqs.org/faqs/aix-faq/>

N.B. Unsolicited email from vendors will not be appreciated.

-----Original Message-----
From: Tony Gallo [mailto:tony_gallo@THRUWAY.STATE.NY.US]
Sent: 13 June 2003 16:19
To: aix-l@Princeton.EDU
Subject: AIX 5.2 vs 4.3.3 differences

We recently upgraded a 7025 6F0 box from 4.3.3 to 5.2. So far the only
problem that the programmers reported was when they run the following to
manipulate the date:
4.3.3 software:
date=030611 (yymmdd)
date=$(($date+20000000))
echo $date
20030611 (this is the
result we want in yyyymmdd format)

5.2 software:

date=030611
date=$(($date+20000000))
echo $date
20012681

They believe that the leading 0 is causing the number to be treated as an
octal number. It is converting it to octal an then doing the addition
causing the difference. I realize to get the date they should have used
standard date functions but since they did this already, can anyone tell me
an easy way around this so they don't have to start changing all their
code??



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:55 EDT