How do I get what users are doing?

Kartik Subbarao subbarao at phoenix.Princeton.EDU
Fri Nov 9 06:16:59 AEST 1990


In article <1990Nov08.131534.10938 at virtech.uucp> cpcahil at virtech.UUCP (Conor P. Cahill) writes:
>In article <16642 at hydra.gatech.EDU> ccastdf at prism.gatech.EDU (Dave) writes:
>>How do I (from C) get the information on what a user is doing.  I have
>>seen the output from a w (who is online, and what they are doing), but
>>I can't figure out where it is coming from.
>
>do a popen("ps"...) or a popen("w"...)

That's probably the simplest way to do things, but at least in the case of "w" we can be a bit
more informative. w finds out who is on from reading /etc/utmp (the format of /etc/utmp and 
/etc/wtmp is described in utmp(5). In order to find out what processes are running, it either
calls ps or is already setgid kmem so it can peek at /dev/kmem. Then it does something to find
out the most "interesting" process for each user and displays it. 

So, to basically answer your question, if you want to find out solely who is on from a C program,
you can use the utmp interface, but if you want processes, I guess a popen to ps might not 
be a bad idea.

	
				-Kartik


 


(I need a new .signature -- any suggestions?)
subbarao@{phoenix or gauguin}.Princeton.EDU -|Internet
kartik at silvertone.Princeton.EDU (NeXT mail)       -|	
SUBBARAO at PUCC.BITNET			          - Bitnet



More information about the Comp.unix.questions mailing list