Hello,
I have an AIX 5.3 system and i created a script to get the last login of users.
The script goes like this:
LAST_LOGIN=`lsuser -a time_last_login $cur_user`
TIME_LOGIN=`perl -e 'print scalar localtime("$LAST_LOGIN")'`
Actually what i do in these two lines is to set a variable (LAST_LOGIN) which is the return of
lsuser -a time_last_login
command. The reason i am doing this is because the return of this command is in a form like this 1304942474 which is not a human date and time and i need to convert it later on.
That is what i am doing in the second line using perl -e to convert this value. The weird thing is that if i simply run in the command line the following command
perl -e 'print scalar localtime(1304942474)'
i get the output Mon May 9 15:01:14 2011 which is correct i suppose. But when i run it through a script replacing the value (1304942474) with ("$LAST_LOGIN") then i get the output
Thu Jan 1 02:00:00 1970 which is obviously wrong.
Any idea what is causing this behaviour and how i should do it to work properly?
Thank you for your attention