I have this script, and I want the output sorted by
first, $date="$month/$day/$year";
and then
$otime="$hours:$minutes:$seconds";
thx much
#!/usr/bin/perl
open (PASSWD,"/etc/passwd") or die "Cannot open /etc/passwd: $!\n";
while (<PASSWD>) {
($user,undef,$uid,undef,$name,undef)=split ":";
if ($uid > 203 and $uid < 1000) {
if ($name eq "") { $name = "Unknown"; }
$last = `lsuser -a time_last_login $user`;
if ($last !~ /time_last_login/) {
$date="Unknown";
$otime="";
$time=0;
} else {
(undef,$time)=split("=",$last);
($seconds,$minutes,$hours,$day,$month,$year,undef) = localtime($time);
$month += 1;
$year += 1900;
$date="$month/$day/$year";
$otime="$hours:$minutes:$seconds";
}
write;
}
}
Authored by: ethanjohnsons
first, $date="$month/$day/$year";
and then
$otime="$hours:$minutes:$seconds";
thx much
#!/usr/bin/perl
open (PASSWD,"/etc/passwd") or die "Cannot open /etc/passwd: $!\n";
while (<PASSWD>) {
($user,undef,$uid,undef,$name,undef)=split ":";
if ($uid > 203 and $uid < 1000) {
if ($name eq "") { $name = "Unknown"; }
$last = `lsuser -a time_last_login $user`;
if ($last !~ /time_last_login/) {
$date="Unknown";
$otime="";
$time=0;
} else {
(undef,$time)=split("=",$last);
($seconds,$minutes,$hours,$day,$month,$year,undef) = localtime($time);
$month += 1;
$year += 1900;
$date="$month/$day/$year";
$otime="$hours:$minutes:$seconds";
}
write;
}
}
Authored by: ethanjohnsons