Hi, Let say I login from home to computer X in linux. What's the command to use in the computer X (linux) to tell the name of my home PC? Thanks, Carson
No.1 | | 454 bytes | |
<ckpun1978@gmail.comwrote in message news:1122231291.079387.48070@ Hi,
Let say I login from home to computer X in linux. What's the command to use in the computer X (linux) to tell the name of my home PC?
'who' will tell you where it thinks you are logged in from. Any resemblance between that and what your home PC calls itself may depend on such things as DNS or hosts entries as well as NAT and DHCP.
No.2 | | 246 bytes | |
hostname ckpun1978@gmail.com wrote: Hi, Let say I login from home to computer X in linux. What's the command to use in the computer X (linux) to tell the name of my home PC? Thanks, Carson
No.3 | | 790 bytes | |
2005-07-29, 14:52(+08), spike: [] >Let say I login from home to computer X in linux. What's the command >to use in the computer X (linux) to tell the name of my home PC? []
If the shell is tcsh, you may find it in $REMTEHST (if utmp contains that information or the shell stdin is a socket (but that generally means it's not an interactive shell)).
If not, you'll need to retrieve the information by yourself from utmp (see who(1) output). You can also pass that information via the TERM environment variable.
Like:
TERM=${TERM}:$(uname) telnet other-host
and in other-host .profile:
case $TERM in *:*) REMTEHST=${TERM#*:} TERM=${TERM%%:*} export TERM ;; esac