D
drew
i have to process a large amount of data and i cannot perform this on
the invidual servers for either security sake or the way we have been setup.
here is the script from the PERL COOKBOOK to show the closest approach
#!/usr/bin/perl
# laston - find out when given user last logged on
use User:went;
use IO::Seekable qw(SEEK_SET);
open (LASTLOG, "/var/log/lastlog") or die "can't open /usr/adm/lastlog: $!";
$typedef = 'L A12 A16'; # linux fmt; sunos is "L A8 A16"
$sizeof = length(pack($typedef, ()));
for $user (@ARGV) {
$U = ($user =~ /^\d+$/) ? getpwuid($user) : getpwnam($user);
unless ($U) { warn "no such uid $user\n"; next; }
seek(LASTLOG, $U->uid * $sizeof, SEEK_SET) or die "seek failed: $!";
read(LASTLOG, $buffer, $sizeof) == $sizeof or next;
($time, $line, $host) = unpack($typedef, $buffer);
printf "%-8s UID %5d %s%s%s\n", $U->name, $U->uid,
$time ? ("at " . localtime($time)) : "never logged in",
$line && " on $line",
$host && " from $host";
}
i have geathered all the passwd files/lastlog file for each server
how do i get getpwuid / getpwnam to work on the the password file that
i gathered and then work on the lastlog of the associated server?
all pointers will be appreciated and thanks.
prasanth
the invidual servers for either security sake or the way we have been setup.
here is the script from the PERL COOKBOOK to show the closest approach
#!/usr/bin/perl
# laston - find out when given user last logged on
use User:went;
use IO::Seekable qw(SEEK_SET);
open (LASTLOG, "/var/log/lastlog") or die "can't open /usr/adm/lastlog: $!";
$typedef = 'L A12 A16'; # linux fmt; sunos is "L A8 A16"
$sizeof = length(pack($typedef, ()));
for $user (@ARGV) {
$U = ($user =~ /^\d+$/) ? getpwuid($user) : getpwnam($user);
unless ($U) { warn "no such uid $user\n"; next; }
seek(LASTLOG, $U->uid * $sizeof, SEEK_SET) or die "seek failed: $!";
read(LASTLOG, $buffer, $sizeof) == $sizeof or next;
($time, $line, $host) = unpack($typedef, $buffer);
printf "%-8s UID %5d %s%s%s\n", $U->name, $U->uid,
$time ? ("at " . localtime($time)) : "never logged in",
$line && " on $line",
$host && " from $host";
}
i have geathered all the passwd files/lastlog file for each server
how do i get getpwuid / getpwnam to work on the the password file that
i gathered and then work on the lastlog of the associated server?
all pointers will be appreciated and thanks.
prasanth