1834650 Members
2019 Online
110069 Solutions
New Discussion

Re: who -R

 
iranzo
Frequent Advisor

who -R

when execute "who -R":
root ttyp1 (PC@IP1)
system pts/0 (HPSERVER1)
root dtremote (PC@IP1)
system dtremote (PC@IP2)
root pts/1 (HPSERVER1)
my PC address is "PC@IP1" .
what command should i use , to find this address ?
thank you .
Bonjour
10 REPLIES 10
Christopher McCray_1
Honored Contributor

Re: who -R

I believe the command you are looking for is
#who -mR

Hope this helps
Chris
It wasn't me!!!!
T G Manikandan
Honored Contributor

Re: who -R

Hello

#who am i
G. Vrijhoeven
Honored Contributor

Re: who -R

Hi,

you can try resolving the name into the ip-adress with
nslookup PC@IP1
or cat /etc/hosts | grep PC@IP1


James Beamish-White
Trusted Contributor

Re: who -R

Do you want to get the system name of whatever machine you're telneting from? Try

who am i -R | awk '{print $6}' | sed 's/[()]//g'

nslookup will find the IP address of the machine, looking in /etc/hosts won't work unless you *don't* use DNS.

More information after more details ;-)

James
GARDENOFEDEN> create light
Bill McNAMARA_1
Honored Contributor

Re: who -R

in your .profile

export DISPLAY=`who am i -R | cut -f2 -d'(' | cut -f1 -d')'|cut -f1 -d':'`:0.0

which is the command you need to find your ip.

Later,
Bill
It works for me (tm)
Roger Baptiste
Honored Contributor

Re: who -R

Malosse,

Do an nslookup on PC@IP1 to get the
IP address. If you are using DHCP, the
IP address will change whenever you login
to the network.

-raj
Take it easy.
iranzo
Frequent Advisor

Re: who -R

when i use cmd "who -mR" or another "who" command:
system return : " system pts/0 (HPSERVER1)" or
more informations .
But I need a command to get my dtremote PC's name only to execute a script, i need a system return like :
"root dtremote (PC@IP1)" .




Bonjour
T G Manikandan
Honored Contributor

Re: who -R

Hello,
You can have the telnet and remote sessions from the #who -R command.
Now you can grep the user tty and the ipaddress from there.
you can then cut the ip-address and then
For example it the tty is pts/ta and the ip is
xx.xx.xx.xx
who -R|grep "pts/ta"|awk -F "(" '{print $2}'|awk -F ")" '{print $1}'

do a
#nslookup
to get the hostname.
Remember the remote machine is a Windows machine,make sure that your dns server has entries for the hostname resolution.
If your network has NT dns server then it is a easy task.Then you can point your Unix machine
to the windows DNS server and modify your /etc/nsswitch.conf file to look into dns for name resolution.
Now your nslookup will give you the NT hostname.

else
you can catch the ip-address.Then do a
ping -a to get the hostname.
harry d brown jr
Honored Contributor

Re: who -R

How about something as complicated as this:


who -R|tr -s " " ""|sed "s/^\([a-z]\{1,8\}\) \([a-z0-9\/]\{1,12\}\) \([A-Za-z]{3\} [0-9]\{2\} [0-9]\{2\}\:[0-9]\{2\}\) \((.*)\)$/\1 \2 \4/"

it will take "who -R" output and return the loginname tty and address:

# who -R
root ttyp1 Oct 29 08:25 (141.123.236.157)
root pts/ta Oct 29 09:31 (vpart2)
# who -R|tr -s " " ""|sed "s/^\([a-z]\{1,8\}\) \([a-z0-9\/]\{1,12\}\) \([A-Za-z]{3\} [0-9]\{2\} [0-9]\{2\}\:[0-9]\{2\}\) \((.*)\)$/\1 \2 \4/"
root ttyp1 (141.123.236.157)
root pts/ta (vpart2)
#


live free or die

harry
Live Free or Die
Christopher McCray_1
Honored Contributor

Re: who -R

How about this:

#who -mR |cut -c40-61 (this was the columns to get the output I needed, yours may be different)

Hope this gets you closer.

Chris
It wasn't me!!!!