mb@rex.cs.tulane.edu (Mark Benard) (10/21/89)
I am trying to determine how to find the 'foreign address' (such as x.cs.tulane.edu.1234, as displayed by netstat -a) of a user who is logged in via rlogin or telnet over the network. Ideally, I would like to be able to display a list of all users logged in and the host or terminal server they are connected from. (Note: last displays this information, but only if rlogin was used.) If there is no easy answer, then I guess that the question becomes: netstat -A gives me protocol control blocks. How do I determine the process associated with a PCB? -- Mark Benard Department of Computer Science INTERNET & BITNET: mb@cs.tulane.edu Tulane University USENET: rex!mb New Orleans, LA 70118
samlb@pioneer.arc.nasa.gov (Sam Bassett RCD) (10/23/89)
On my Ultrix 3.0 system here (4.3BSD derived), 'who' gives me just that info. I am not an expert on SysV 'who's, but I know that they're different . . . Sam'l Bassett, Sterling Software @ NASA Ames Research Center, Moffett Field CA 94035 Work: (415) 694-4792; Home: (415) 969-2644 samlb@well.sf.ca.us samlb@ames.arc.nasa.gov <Disclaimer> := 'Sterling doesn't _have_ opinions -- much less NASA!'
montnaro@sprite.crd.ge.com (Skip Montanaro) (10/24/89)
In article <3539@amelia.nas.nasa.gov> samlb@pioneer.arc.nasa.gov (Sam Bassett RCD) writes:
On my Ultrix 3.0 system here (4.3BSD derived), 'who' gives me
just that info. I am not an expert on SysV 'who's, but I know that
they're different . . .
I think it depends how good a job the vendor has done incoporating all the
little odds'n'ends that go into "Berkeley UNIX compatibility". Stellar's
'who' command prints the originating host, while HP-UX (at least as of 6.5)
does not.
--
Skip Montanaro (montanaro@crdgw1.ge.com)
bph@buengc.BU.EDU (Blair P. Houghton) (10/25/89)
In article <MONTNARO.89Oct23141238@sprite.crd.ge.com> <montanaro@crdgw1.ge.com> (Skip Montanaro) writes: >In article <3539@amelia.nas.nasa.gov> samlb@pioneer.arc.nasa.gov (Sam Bassett RCD) writes: > > On my Ultrix 3.0 system here (4.3BSD derived), 'who' gives me > just that info. I am not an expert on SysV 'who's, but I know that > they're different . . . > >I think it depends how good a job the vendor has done incoporating all the >little odds'n'ends that go into "Berkeley UNIX compatibility". Stellar's >'who' command prints the originating host, while HP-UX (at least as of 6.5) >does not. Screw 'who': -----------------------------Clip 'n' compile------------------------------- #include <stdio.h> #include <utmp.h> /* Where the current logins are stored. */ #define LOGFILE "/etc/utmp" extern char *rindex(); main() { char *tty, *ttyname(), *nptr; struct utmp U; FILE *fp, *fopen(); fp = fopen( LOGFILE, "r"); /* Get stdin's tty's name. */ tty = ttyname(0); /* "/dev/ttyxx" ==> "ttyxx" */ nptr = 1 + rindex(tty,'/'); /* Loop through login log, printing remote * * host for all that have this tty's name. */ while( fread( (char *)&U, sizeof(struct utmp), 1, fp ) ) if ( (*U.ut_name != '\0') && (strcmp(nptr, U.ut_line) == 0) ) printf( "%s\n", U.ut_host); } ---------------------------------------------------------------------------- This is a rather thoroughly altered version of something I got from someone else. I forget who. (No doubt their lawyers will remind me :-). --Blair "An oldie but a goodie."