Finding your remote host's name

Don Lewis del at thrush.mlb.semi.harris.com
Fri Jun 8 11:03:08 AEST 1990


In article <1211 at tuewsd.win.tue.nl> wswietse at lso.win.tue.nl (Wietse Venema) writes:
>scm at 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 at mlb.semi.harris.com     PO Box 883   MS 62A-028
Phone:     (407) 729-5205              Melbourne, FL  32901



More information about the Comp.unix.questions mailing list