[comp.unix.programmer] User login time

6600bori@ucsbuxa.ucsb.edu (Boris Burtin) (02/05/91)

I have been assigned by my company the task of writing a C program on a Sun  
Sparcstation 1+ that will keep a user log.  The general idea is that it 
determines when they logged on and off, and writes the information to a file.
The problem is this: I would like to determine both the login and logout times
in one program (executed from .logout).  Is there a library function that
returns the time that the user logged into the machine?  Or does that have to
be done at the time that it happens (from .login)?

	- Boris Burtin
	(6600bori@ucsbuxa.ucsb.edu)

barmar@think.com (Barry Margolin) (02/05/91)

In article <8836@hub.ucsb.edu> 6600bori@ucsbuxa.ucsb.edu (Boris Burtin) writes:
>I have been assigned by my company the task of writing a C program on a Sun  
>Sparcstation 1+ that will keep a user log.  The general idea is that it 
>determines when they logged on and off, and writes the information to a file.

SunOS already maintains just such a file.  Try the "last" command.
--
Barry Margolin, Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar

mike@bria.UUCP (Michael Stefanik) (02/06/91)

In article <8836@hub.ucsb.edu> ucsbuxa.ucsb.edu!6600bori (Boris Burtin) writes:
>I have been assigned by my company the task of writing a C program on a Sun  
>Sparcstation 1+ that will keep a user log. [...]

A file (usually called /etc/wtmp or /usr/adm/wtmp) is updated by /bin/login;
and on many machines, a "lastlogin" type of file is maintained on both
the last successful and unscuccessful login for users.
-- 
Michael Stefanik                       | Opinions stated are not even my own.
Systems Engineer, Briareus Corporation | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
technoignorami (tek'no-ig'no-ram`i) a group of individuals that are constantly
found to be saying things like "Well, it works on my DOS machine ..."