Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!princeton!phoenix!subbarao From: subbarao@phoenix.Princeton.EDU (Kartik Subbarao) Newsgroups: comp.unix.questions Subject: Re: How do I get what users are doing? Keywords: w, what, who, finger Message-ID: <3933@idunno.Princeton.EDU> Date: 8 Nov 90 19:16:59 GMT References: <16642@hydra.gatech.EDU> <1990Nov08.131534.10938@virtech.uucp> Sender: news@idunno.Princeton.EDU Lines: 29 In article <1990Nov08.131534.10938@virtech.uucp> cpcahil@virtech.UUCP (Conor P. Cahill) writes: >In article <16642@hydra.gatech.EDU> ccastdf@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@silvertone.Princeton.EDU (NeXT mail) -| SUBBARAO@PUCC.BITNET - Bitnet