SUMMARY: How to see everything with last

From: SI-Gaetan Boudreau (boudreg@IRCM.UMontreal.CA)
Date: Mon Apr 29 1996 - 12:18:42 CDT


Original question:
Does anyone know I can see all of the machine name that is ouput in the
third column of the command "last".

Example of the output:
boudreau pts/13 cleopatre.pasteu Fri Apr 12 08:16 - 08:22 (00:06)

I know the data is kept in /var/adm/wtmpx but is not really
searchable.
-----------------------------------------------------------------------

Thank you to all that replyied.

The best solution was given by
scott hollatz <shollatz@d.umn.edu>
who wrote a small C program that reads /var/adm/wtmpx. We can
costumize the output by changing the program:

I wrote this as part of another project. It will read and display the
wtmpx
file, displaying the full host name. (I pipe the output of this
program to
another. Lines that have user names on them don't begin with a '.'.)

The following works for Solaris 2.3, 2.4, and 2.5.
-----------------------------------------------
/*
** @(#) stmpx.c - view utmpx or wtmpx file
** 19940823.1411 s.a.hollatz
**
** USE
** stmpx file
*/

#include <stdio.h>
#include <utmpx.h>
#include <sys/time.h>

/**********************************************************************
*******
* main
      *
***********************************************************************
******/

int main( int argc, char **argv )
{
        char *fName; /* data file name */
        FILE *f; /* utmpx or wtmpx file pointer
*/
        struct utmpx tmpx; /* data record */
        time_t seconds;
        struct tm *t;
        char buff[ 32 ]; /* for time processing */

/* interpret the command line */

        if ( !--argc )
        {
                fprintf( stderr, "use: stmpx file\n" );
                exit( 1 );
        }

        fName = *++argv;

/* open the data file, read and print contents */

        if ( !(f = fopen( fName, "r" )) )
        {
                fprintf( stderr, "cannot open %s\n", fName );
                exit( 3 );
        }

        while ( !feof( f ) && fread( &tmpx, sizeof( struct utmpx ), 1,
f ) )
        {
                seconds = (time_t) tmpx.ut_tv.tv_sec;
                t = localtime( &seconds );

                /* build the time string in yyyymmdd.hhmmss format */
                sprintf( buff, "%4d%02d%02d.%02d%02d%02d",
                        t->tm_year + 1900,
                        t->tm_mon + 1,
                        t->tm_mday,
                        t->tm_hour,
                        t->tm_min,
                        t->tm_sec );

                printf( "%s %s %s %s\n",
                        tmpx.ut_user, buff, tmpx.ut_host, tmpx.ut_line
);
        }

        fclose( f );
}

-- 
=====================================================================
,   @     _{)_  ,Gaetan Boudreau, ing
 \/( )\/\/\  /\/ Ingenieur de systemes/System Engineer
   /=\    /==\   IRCM (Institut de recherches cliniques de Montreal/
  /___\   |/\|         Clinical Research Institute of Montreal)
  _/ \_  \# _#   tel: 514-987-5563   fax: 514-987-5644
Internet: Gaetan_Boudreau@IRCM.UMontreal.CA



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:59 CDT