Thanks to:
Charles Seeger
Bryan Mawhinney
Xaniotakis Vaggelis
Scott D. Yelich
Gerhard den Hollander
Neil Clifford
David Mitchell
Michael F Gordon
Delaney, Ray (FUSA)
My original question was:
---------------------------
Hello,
I was wondering if there was a way, without coding, that one can calculate  the seconds since 1 Jan 1970, 00:00:00 till present. This is preferably on  Solaris 2.6  I've checked the date command but the GNU version only supports this. 
---------------------------
 
Most replies were that I should use perl(_UNFORTUNATELY_ not allowed on this
production box):
 perl -e 'print time, "\n"'
However Charles Seeger had THIS to say:
----------------------------------------------------------
On Solaris you can use truss like this (sh/ksh syntax):
        set -- `truss -t time date 2>&1 >/dev/null`
        while [ $# -gt 1 ]; do shift ; done
        TIME=$1
Or, if you have perl:
        TIME=`perl -e '$val=time; print -- "$val\n"'`
More portable, though more complicated, sh and ksh versions:
        set -- `env LC_ALL=C LC_TIME=C LANG=C date -u '+%Y %j %H %M %S'`
        DAYS=`expr 365 \* \( $1 - 1970 \) + \( $1 - 1969 \) / 4 + $2 - 1`
        # XXX This will begin to fail in 2100 A.D. unless the following line
        # XXX that adjusts for 100 and 400 years periods is uncommented.
        #[ $1 -gt 2100 ] && DAYS=`expr $DAYS - \( $1 - 2000 \) / 100 \
        #                               + \( $1 - 2000 \) / 400`
        TIME=`expr $5 + 60 \* \( $4 + 60 \* \( $3 + 24 \* $DAYS \) \)`
        set -- $(env LC_ALL=C LC_TIME=C LANG=C date -u '+%Y %j %H %M %S')
        DAYS=$(( 365*($1 - 1970) + ($1 - 1969)/4 + $2 -1 ))
        # This will begin to fail in 2100 A.D. unless the following line
        # that adjusts for 100 and 400 year periods is uncommented.
        #(( $1 >= 2100 )) && DAYS=$(( $DAYS - ($1-2000)/100 + ($1-2000)/400 ))
        TIME=$(( $5 + 60*($4 + 60*($3 + 24*$DAYS)) ))
FWIW, I originally figured out the sh version about five years ago to
set the LASTCHG field in the shadow password file during jumpstarts.
HTH,
Chuck
----------------------------------------------------------
 
-- Sugan Moodley The Internet Solutions, Rosebank, Gauteng, South Africa. +27 11 283 5500The mosquito is the state bird of New Jersey. -- Andy Warhol
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:14:06 CDT