Operating System - HP-UX
1753419 Members
4768 Online
108793 Solutions
New Discussion юеВ

dynamically set the IP address in DISPLAY variable

 
david.deng
Occasional Advisor

dynamically set the IP address in DISPLAY variable

I need dynamically set the IP address in DISPLAY variable. After I using windows command line telnet to HP UX 11i version 1, I run who am I -muR, it give me the part of ip address like ::ffff:172.16.12. The acctual ip address should be 172.16.123.87. How can I get the full ipv4 address or ipv4-mapped-ipv6 address.
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: dynamically set the IP address in DISPLAY variable

Shalom,

few way to do it.

HOSTNAME is already set.

So you can use nslookup or dig to get the ip address.

You will need to script it into a variable.

The exact data you want comes from ifconfig

In HP-UX ifconfig is a root only command and you need to give all users sudo permission to use it in order to do what you want.


SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
TwoProc
Honored Contributor

Re: dynamically set the IP address in DISPLAY variable

How about...
$> DISPLAY=$(who am i -R |sed -e "s/^.*(//" -e "s/)$/:0.0")
$> echo $DISPLAY

See if that works for you.
We are the people our parents warned us about --Jimmy Buffett
david.deng
Occasional Advisor

Re: dynamically set the IP address in DISPLAY variable

The problem is who am i -R only return part of the ip address.
James R. Ferguson
Acclaimed Contributor

Re: dynamically set the IP address in DISPLAY variable

Hi David:

TwoProc meant to include a closing delimiter to his second 'sed' script:

# DISPLAY=$(who am i -R |sed -e "s/^.*(//" -e "s/)$/:0.0/")

Regards! :-)

...JRF...
david.deng
Occasional Advisor

Re: dynamically set the IP address in DISPLAY variable

Hi James,

Your scripts works only when the "who am I" return the whole ip address. Right now if I using Exceed CDE to login, "who am I" return whole ip. However, if I using telnet from windows command line to login, "who am I" only return ip address like ::ffff:172.16.12.
TwoProc
Honored Contributor

Re: dynamically set the IP address in DISPLAY variable

Thanks for the catch on that James. I did leave it off.

David, I didn't try with a Windows Telnet - sorry I just used ssh command. Which brings up the question... Why are you using telnet? Why is it still enabled on your server? From a security standpoint - it really should be turned off, and you should convert to ssh. You can download a free version of "putty" to get the same character based interface, and it CAN forward X11 data in the tunnel, so that you can still connect to your Exceed display.

I know that's not what you asked - just trying to pass on some advice. Feel free to ignore if you have circumstances that allow telnets use without risk.

Sadly, I can't test the problem using telnet for you, because I don't have any systems that have it turned on anylonger.

However, you *could* try just this one thing:
add your ip address to the HP server's /etc/hosts file. That way, instead of listing an IP address from "who am i -R" you'd get a machine name instead.On my server, if the server knows my machine name (via /etc/hosts, dns, whatever and however) it prints that instead of an IP address. And DISPLAY=urcomputer:0.0 or DISPLAY=urcomputer.urdomain.com:0.0 or DISPLAY=xxx.xxx.xxx.xxx:0.0 is all just as good as any of the others.

This last suggestion, at least to me - might stand a reasonable chance of working out for you via telnet, in combination with the fixed DISPLAY command that JRF posted.
We are the people our parents warned us about --Jimmy Buffett
TwoProc
Honored Contributor

Re: dynamically set the IP address in DISPLAY variable

crickets ....
We are the people our parents warned us about --Jimmy Buffett