REMOTEHOST
David L. Crow
crow at waterloo.austin.ibm.com
Fri Mar 22 05:59:16 AEST 1991
>In AIX/RS6000, is there a way to find out from where you are actually
>login'ed ?
Following is the solution that I use for determining the host that
I have logged in from. It is an all-shell solution that I use on a
server for InfoExplorer so that the graphics version can be displayed
on the X-Server from which you login.
# The first statement sets the TTY variable to be what is returned from
# the 'tty' command without the /dev/ ie if tty returned '/dev/pty/3',
# then all we want is 'pty/3'
# The second statement determines the display name for X to use. I use
# who to determine which machine we are coming from. We grep on the tty
# found in the previous step. The awk gets the last item on the line
# (i.e. the hostname). The last item is of the form (host.domain...). The
# sed will strip the parenthesis and the domain leaving only the hostname.
# Then we append the ":0" to make it the display name.
TTY=$(tty | sed 's/\/dev\///')
DISPLAY=$(who | grep $TTY | awk '{print $NF}' | sed
's/(\([a-zA-Z0-9_]*\).*/\1/'):0
export TTY DISPLAY
All that you should have to change is to take the ":0" off the end of the
DISPLAY assignment statement and maybe change the name to something more
meanningful like FROMHOST.
I don't claim that this is the best or only solution. It is one that I
came up with on the fly and it seems to work very well. The only problem
that I have add is if the machine that you are logging in to cannot do
internet ID to hostname translation correctly (ie the host is not defined
in /etc/hosts or on the nameserver), then the value for DISPLAY will be
set to the first octet of the internet address appended to ":0" since I
use the period as a delimiter.
If you have any questions feel free to ask (either by post or email).
- This is only an exhibition, not a competition, so please....no wagering. -
David Crow (512) 823-4834 IBM VNET: dlcrow at austin
AIX Systems Graphics Development Internet: crow at waterloo.austin.ibm.com
------ Any opinions expressed are those of me and not of my employer. ------
More information about the Comp.unix.aix
mailing list