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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KornShell function works in AIX 5.3 and 7.1 but not 6.1

Status
Not open for further replies.

macrun95

Technical User
Dec 5, 2005
28
US
I'm running the following code on three different levels of AIX and getting different results. It works fine on 5.3 and 7.1 but not 6.1. I'm running ksh version 88 on all three systems.

# Function GetDate nDays [format]
function GetDate
{
typeset -i nDays=$1; format=$2
eval $(echo $TZ | sed '
s!\([^-0-9]*\)\([-0-9]*\)\(.*\)!typeset -i localOffset=\2;zon1=\1;zon2=\3!')
TZ=$zon1$((localOffset-24*nDays))$zon2 date $format
}
prevdate=`GetDate -1 +%Y%m%d`
print $prevdate


Any idea on why it won't work on AIX 6.1?
 
Works for me, perhaps your 6.1 installation is incomplete. Go rebuke your Sys admin.
Code:
==> uname -a
AIX bigblack 1 6 0000542A4C00
==> oslevel
6.1.0.0
==> function GetDate
> {
> typeset -i nDays=$1; format=$2
> eval $(echo $TZ | sed '
> s!\([^-0-9]*\)\([-0-9]*\)\(.*\)!typeset -i localOffset=\2;zon1=\1;zon2=\3!')
> TZ=$zon1$((localOffset-24*nDays))$zon2 date $format
> }
==> prevdate=`GetDate -1 +%Y%m%d`
==> print $prevdate
20140615
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top