Hi,
I have searched, read and tried, but no luck.
I have this code:
#!/bin/perl -w #-d
use strict;
use POSIX qw(strftime);
my $getprpw_list="/usr/lbin/getprpw -l";
my $host = "nbsol151";
my $user = "genadmin";
my %uid;
my %spwchg;
my %upwchg;
my %slogint;
my %ulogint;
my %alock;
my %lockout;
open (GETPRPW, '-|', "$getprpw_list $user");
while (<GETPRPW>) {
chomp;
if ( /uid=(.*?),/ ) { my $uid{$host} = $1 }
if ( /spwchg=(.*?),/ ) { my $spwchg{$host} = $1 }
if ( /upwchg=(.*?),/ ) { my $upwchg{$host} = $1 }
if ( /slogint=(.*?),/ ) { my $slogint{$host} = $1 }
if ( /ulogint=(.*?),/ ) { my $ulogint{$host} = $1 }
if ( /alock=(.*?),/ ) { my $alock{$host} = $1 }
if ( /lockout=(.*?)$/ ) { my $lockout{$host} = $1 }
}
close (GETPRPW);
printf "spwchg : $spwchg{$host}\n";
The result is:
spwchg : Thu Feb 12 08:19:32 2009
Which is okay.
But I need to put 4 of those dates, plus some more data , on 1 line.
Therefore I would like to have the date converted to something shorter.
Like:
spwchg : 09-02-12/08:19:32
I tried with localtime and strftime, but it does not work for me.
That is to say, I cannot make it work.
Anybody out there that knows the easiest way to convert
"Thu Feb 12 08:19:32 2009" into "09-02-12/08:19:32" ??
Thanks,
E.J.