Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!rpi!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!tundra From: tundra@ux1.cso.uiuc.edu (John Kemp) Newsgroups: comp.sys.hp Subject: GETUTENT /ETC/UTMP NOT WORKING(?) Message-ID: <1990Sep17.172858.29044@ux1.cso.uiuc.edu> Date: 17 Sep 90 17:28:58 GMT Sender: tundra@ux1.cso.uiuc.edu (John Kemp) Organization: University of Illinois at Urbana Lines: 59 Is this a bug or am I doing something stupid? How does one go about scanning the list of currently logged in users? I thought "getutent" as the way to do it. Unfortunately, this call produces garbage in the "ut_user" and "ut_line" fields. Any suggestions? (Test program and output listed below) -------- john kemp ( ( )_ internet - kemp@uiatma.atmos.uiuc.edu ----- ( ( __) decnet - uiatmb::kemp --- univ of illinois (_ ( __) bitnet - {uunet,convex} -- dept of atmos sci .(____). !uiucuxc!uiatma!kemp - 105 s gregory ave ... phone - (217) 333-6881 - urbana, il 61801 ... fax - (217) 444-4393 ******************** SAMPLE PROGRAM ******************** /* * Print out /etc/utmp records. */ #include #include #include struct utmp *ut; main() { utmpname("/etc/utmp"); setutent(); while ( (ut = getutent()) != NULL ) { fprintf(stderr,"user: %8c \n",ut->ut_user); fprintf(stderr,"id: %4c \n",ut->ut_id); fprintf(stderr,"line: %12c\n",ut->ut_line); fprintf(stderr,"pid: %d \n",ut->ut_pid); fprintf(stderr,"type: %d \n",ut->ut_type); fprintf(stderr,"host: %16c\n",ut->ut_host); } } ******************** OUTPUT: ******************** user: 8 id: @ line: D pid: 0 type: 2 host: ` user: 8 id: @ line: D pid: 0 type: 1 host: ` Add Nauseum with PID's incresing and so on...