Home About BC DR HA Support Training Download
You are here: Home/ GlobalSysAdmin/ AIX/ Please Login or Register

-
Current Location
-

js
  GlobalSysAdmin
    AIX
-
AIX Admin Methodology
Global Consolidation Project
All AIX admins should join
www.aixexpert.com


Join our LinkedIn Group
AIX Advanced Technical Experts
Contract Opportunities

www.LinkedIn.com

-
digg Digg this page
del.icio.us Post to del.icio.us
Slashdot Slashdot it!


LPAR Leasing
Lease an AIX / i5 LPAR
Reduce your costs

www.mtxia.com

Server Leasing
Lease a Server off-site
Reduce your costs

www.mtxia.com

Data Center Automation
Business Continuity and DR
Virtualization/Consolidation

www.mtxia.com

HMC Service
Hardware Management Console
Manage Remote AIX / i5 LPARs

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

Disaster Recovery
Small Business Oriented
Off-Site Facilities

www.mtxia.com

IBM pSeries / iSeries
Reduce your Costs
Off-Site Server Hosting

www.mtxia.com

The following as a Korn shell function to determine if a specified year is a leap year.


#!/bin/ksh
################################################################
####    Korn Shell function to determine whether or not a specified
####    4 digit year is a leap year.  This function is designed to
####    return the result as the return status of the function.
####    The isLeap function returns 0 if the year is a leap year,
####    and 1 if it is not a leap year.
####
####    Load this file into your current environment as follows:
####    
####    . ./isLeap.ksh
####    
####    Thats "dot-space-dot-slash-isLeap-dot-ksh"
####
####    You will then be able to issue the command "isLeap"
####    from your current environment.
####
####    SYNTAX: isLeap [-d] [-y ####]
####
####                   -d    print the number of days in february to STDOUT
####
####                   -y    Require a 4 digit year to be specified.  
####                         performs leap year test against specified year.
####
####    AUTHOR: Dana French
####    EMAIL: dfrench@mtxia.com
####
################################################################
function isLeap {

STATUS="-1"
DFLAG=""
YFLAG=""
YEAR=`date +"%Y"`
while getopts ':dy:' NAME
do
    case "_${NAME}" in
        "_d") DFLAG="1";;
        "_y") YFLAG="1"; YEAR="${OPTARG}";;
        "_?") print "
SYNTAX: isLeap [-d] [-y ####]

        -d    print the number of days in february to STDOUT

        -y    Require a 4 digit year to be specified.  
              performs leap year test against specified year.

"; return ${STATUS};;
esac
done

if [[ "_${YEAR}" != "_" && ${#YEAR} -eq 4 ]]
then

    STATUS="1"
    [[ $(( ${YEAR} % 4 )) -eq 0 && $(( ${YEAR} % 100 )) -ne 0 ]] ||
    [[ $(( ${YEAR} % 400 )) -eq 0 ]] && STATUS="0"

    if [[ "_${DFLAG}" != "_" &&  "_${DFLAG}" = "_1" && "_${STATUS}" = "_0" ]]
    then
        print "29"
    fi
    if [[ "_${DFLAG}" != "_" &&  "_${DFLAG}" = "_1" && "_${STATUS}" = "_1" ]]
    then
        print "28"
    fi
else
    print "ERROR: Invalid year specified"
fi
return ${STATUS}
}

-
Leap Year Function
-
 


LPAR Leasing
Lease an AIX / i5 LPAR
Reduce your costs

www.mtxia.com

Server Leasing
Lease a Server off-site
Reduce your costs

www.mtxia.com

Data Center Automation
Business Continuity and DR
Virtualization/Consolidation

www.mtxia.com

HMC Service
Hardware Management Console
Manage Remote AIX / i5 LPARs

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com

Disaster Recovery
Small Business Oriented
Off-Site Facilities

www.mtxia.com

IBM pSeries / iSeries
Reduce your Costs
Off-Site Server Hosting

www.mtxia.com