home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.aix
- Path: sparky!uunet!spillman!tye
- From: tye@spillman.uucp (E. Tye McQueen)
- Subject: Re: last command?
- Message-ID: <1993Jan07.210317.25025@spillman.uucp>
- Date: Thu, 07 Jan 1993 21:03:17 GMT
- References: <9301060106.AA10395@ecnet.ec> <1993Jan6.131057.23213@eagle.lerc.nasa.gov>
- Organization: Spillman Data Systems
- Lines: 55
-
- fsfrick@lerc.nasa.gov (David Fricker) writes:
- )In <9301060106.AA10395@>, jhidalgo@ecnet.ec (Javier Hidalgo E.) writes:
- )> Hi folks, please if someone know a command similary to last
- )> command for read from tacacs.wtmp and failedlogin files, because
- )> last only read of wtmp, and information is good.
- )
- )Try 'who <filename>'. 'who' accepts (as an argument) a file to look
- )at instead of the default /etc/utmp. You may want some way to
- )reverse the order to look more like 'last', though.
- )
- )Of course, 'who' doesn't give you all the info that 'last' does, but
- )it is a start.
-
- Here is a Perl script that reads "utmp" records. It hasn't been
- prettied up. Currently you pass it a single argument which is the
- username whos login/outs you want to see.
-
- If you are familiar with Perl this is easy to change to show just
- about anything you want.
-
- Just change the "64"s and the unpack string to port to a different
- machine. Yes, it's very quick and very dirty.
-
- ----- Delete this line and above -----
- #!/usr/bin/perl
- # Dumps contents of /usr/adm/wtmp in human-readable format
-
- eval 'exec perl -S $0 ${1+"$@"}'
- if 0;# not already running under PERL;
-
- # /etc/utmp
- open( WTMP, "</usr/adm/wtmp" )
- || die "Can't read /usr/adm/wtmp: $!\n";
-
- @type= split(' ',"MT RLVL BOOT TIME INIT LOGIN USER DEAD ACCT");
-
- $oinit= "None";
-
- while( 64 == sysread( WTMP, $rec, 64 ) ) {
- ( $user, $init, $line, $type, $pid, $terminate, $exit, $time, $host )=
- unpack( "A8A14A12slssLA16", $rec );
- if( $ARGV[0] eq $user || "" ne $oinit && $init eq $oinit ) {
- print $init ? "Init=$init" : "", $user ? " User=$user" : "",
- $line ? " Line=$line" : "", $pid ? " PID=$pid" : "",
- " Type=", $type, $type[$type] ? ":$type[$type]" : "",
- $terminate ? " End=$terminate" : "",
- $exit ? " Exit=$exit" : "", " Time=",
- sprintf("%02.2d:%02.2d:%02.2d %02.2d/%02.2d/%d",
- (localtime($time))[2,1,0,4,3,5]),
- $host ? " Host=$host" : "", "\n";
- $oinit= ( $ARGV[0] eq $user ) ? $init : "";
- }
- }
- # Line values: "run-level_" "system boot" "old time" "new time"
- ----- Delete this line and below -----
-