login: TEST7
TEST7's Password:
Your password will expire: Wed Feb 19 14:28:08 2003
How can I the same information become in a script (as example
in the .profile)?????????
My login starts with .profile. These File is a menue with 24 lines and the message " Your password ....." disappear
to the top of the screen and the user can't see the message.
My System is a AIX 4.3.2
All Users are defined with pwdwarntime=7
I believe you need someone with a bit more AIX experience than I have (especially since it's been years since I have been on one) but the concept should be the same.
Find your secure password file (try /etc/security/passwd) and look for the lastupdate field.
You should be able to grab out the info from the lastupdate field and using Perl figure out when it will expire.
Take a look at my datecalc script which has been posted to this site. If you use it together with a little bit of algebra you should be able to do what you want.
I just displayed my system clock and got 1046356359.
#!/u/bin/perl
# (Your location of Perl may be different)
===========================================
$epoch= time ();
print "$epoch\n";
Output of this....
# ./cd.pl
1046442456
To get this down to days (if your not worried about how many hours, minutes, seconds...)
#!/u/bin/perl
#
# checkdate - a script to check a date (how long ago)
# Parameter 1 is entry from /etc/shadow - 3rd field - SUN OS
# Created 05/07/02 HOG
# =======================================
# Set up variables
$getepoch= time () /60 /60 /24 ;
($nowepoch, $junk) = split (/\./, $getepoch, 2);
$arguement = $ARGV[0];
$diff=$nowepoch - $arguement;
print "Password reset $diff days ago - $nowepoch - $arguement\n";
Output of this...
# ./checkdate.pl 11989
Password reset 122 days ago - 12111 - 11989
I guess that I would have to go with perl as the best game in town. That first script that RTM posted can actually be condensed into:
perl -e 'print time(),"\n"'
(Note that the above line ends with double quote, then single quote.)
However, I'm not sure why you want to do this. I thought that you had a data file with the raw seconds already in it. I was just using the current time as an example.
Not sure about the date(1) on AIX, but many date commands have this as an option. GNU date uses the +%s modifier, and at least one of the BSD's have a date command that allows you to show seconds since 1970.