Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange Calculations with AIX 5.1

Status
Not open for further replies.

tnelson1

MIS
Jul 18, 2001
17
US
We have a script for doing backups. These backups happen on Saturday (6) and they do different types of backups on odd and even weeks. So, we have an "if" statement similar to what I posted below.

if [[ $(date +%u) -eq 6 ]] && [[ $(( $(date +%U ) %2 )) -eq 0 ]]
then do something
else do something else

The problem comes in with the "$(date +%U ) %2" section. The "date +%U" returns a two digit number representing the week in the year. For some reason in AIX 5.1, (I could not reproduce this in 4.3.3), the script errors out whenever the number starts with a "0" and ends with a "8" or a "9". So in the 8th and 9th week (08 and 09), our script bombed out. I've tryed various calculation toward this. I've found that 028 and 029 do the same thing. Other number combinations are not affected (i.g. 05, 06, 07, 027, etc). I've only seen this on 5.1 machines (I don't have any with 5.2 yet). AIX 4.3.3 machines are fine. Has anybody else seen this? or know of a fix/APAR/PTF for it?

Oh yeah, we are also on ML04.

Thanks,
Tim

 
i think this must be another "improvement" in ksh, perhaps the numbers are interpreted as octal. it might fix it to do a string comparison rather than numeric.

IBM Certified -- AIX 4.3 Obfuscation
 
I think I found a work around. It looks like the ksh in AIX 5.x interprets numbers starting with 0 as octal. Numbers like 08 and 09 would not be valid numbers in octal. So, I decided to try using ksh93 for the script, instead of the older ksh. It now seems to work. ksh93 must be more forgiving, or doesn't assume 0 means octal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top