Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uflorida!mlb.semi.harris.com!thrush.mlb.semi.harris.com!del From: del@thrush.mlb.semi.harris.com (Don Lewis) Newsgroups: comp.unix.questions Subject: Re: Finding your remote host's name Message-ID: <1990Jun8.010308.19410@mlb.semi.harris.com> Date: 8 Jun 90 01:03:08 GMT References: <1990Jun6.091842.11335@dlcq15.datlog.co.uk> <1211@tuewsd.win.tue.nl> Sender: news@mlb.semi.harris.com Organization: Harris Semiconductor, Melbourne FL Lines: 28 In article <1211@tuewsd.win.tue.nl> wswietse@lso.win.tue.nl (Wietse Venema) writes: >scm@dlcq15.datlog.co.uk (Steve Mawer) writes: > >>If I `rlogin' from machine1 to machine2, is there a simple and (relatively) >>portable way to find out on machine2 the name of machine1? I'd like to do >>this from a shell script if possible, but I'm willing to write C code if >>necessary. > >/* fromhost - print name of host we are logged in from */ > [ code deleted ] > > if (getpeername(0, &sa, &length) >= 0) { ^^^^^^^^^^^^^ this won't work. [ code deleted ] Hmn. Fd 0 (or 1 or 2) is not connected to a socket when you rlogin. It is connected to a pseudo tty. Rlogind, or its equivalent sits between the other side of the pty and the socket. Therefore, getpeername() won't work, unless you make a habit of using rsh for remote logins ;-). -- Don "Truck" Lewis Harris Semiconductor Internet: del@mlb.semi.harris.com PO Box 883 MS 62A-028 Phone: (407) 729-5205 Melbourne, FL 32901