1833323 Members
3307 Online
110051 Solutions
New Discussion

Re: exporting DISPLAY

 
gary phipps
Frequent Advisor

exporting DISPLAY

Hi all,

I'm tryin to write a script that runs an x script on a remote terminal. It gets the ip address of the user from the who command, sets the DISPLAY variable to point back to the user's pc and runs the x command. This works fine until someone dials in to the system console.
Does anyone know how to pick up the ip address of someone logged into the console, or of another way round this?

Thanks in advance,

Gary.
13 REPLIES 13
John Meissner
Esteemed Contributor

Re: exporting DISPLAY

You can either use:
who -mT

or the last command:
last -R | grep username | grep in$
All paths lead to destiny
Bill Hassell
Honored Contributor

Re: exporting DISPLAY

You can put this into /etc/profile or .profile:

export DISPLAY="$(/usr/bin/who -muR | awk '{print $NF}'):0.0"

It will automatically set the name or IP address of the incoming machine. NOTE: you mentioned: 'dial in to the system console' Normally, this is a serial port. If you have the serial port connected to a terminal server, the performance will be very, very slow for Xwindows. It is much better to use a local terminal emulator rather than incur the large data transactions used by Xwindows.


Bill Hassell, sysadmin
Robert-Jan Goossens
Honored Contributor

Re: exporting DISPLAY

Hi Gary,

This what I use in my .profile

# -- Do trick to set the display in case of remote login
HOST=`who am i -R |awk '{print $NF}' | sed "s/(\(.*\))/\1/"`
if [ "$HOST" != "" ] && [ "$HOST" != ":0" ] && [ "$HOST" != ":0.0" ];
then
if [ "$HOST" = `who am i -R |awk '{print $NF}' | sed "s/(\(.*\))/\1/"` ]
then
HOST=$HOST:0.0
fi
echo " +--<<"
echo " | Remote login detected, setting DISPLAY to $HOST"
echo " +-->>"
DISPLAY=$HOST
export DISPLAY
fi

Robert-Jan.
Armin Feller
Honored Contributor

Re: exporting DISPLAY

Hi,

perhaps you can find further informations on this issue by following url:

http://www.docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/B2355-90136/B2355-90136_top.html&con=/hpux/onlinedocs/B2355-90136/00/00/7-con.html&toc=/hpux/onlinedocs/B2355-90136/00/00/7-toc.html&searchterms=Managing%7cBSD&queryid=20030117-065101

have also a look at:

http://www.docs.hp.com

and search for BSD, I think that is the way to monitor remote running X sessions.

Regards ...
Armin
gary phipps
Frequent Advisor

Re: exporting DISPLAY

thanks for the responses but none of them returned an IP address. I've decided to go down an alternate route but if aynone has any other suggestions I'll be glad to hear them.

Thanks again,

Gary.
Jochen Heuer
Respected Contributor

Re: exporting DISPLAY

Hi Gary,

what do you mean with 'dial in to the system console'? Does he use a modem? If so it isn't possible because then the remote site does not have an ip address ...

Or have I misunderstood your question?

Regards,

Jochen
Well, yeah ... I suppose there's no point in getting greedy, is there?
gary phipps
Frequent Advisor

Re: exporting DISPLAY

Jochen,

yes, they are using a modem. Can you think of any way around this?



Gary.
Jochen Heuer
Respected Contributor

Re: exporting DISPLAY

Hi Gary,

the only way I can think of is to use ppp or slip instead of a direct connection to getty.

But I have never configured ppp on HP-UX. I am not sure if it's even available (did not find anything on the porting site) ...

Regards,

Jochen
Well, yeah ... I suppose there's no point in getting greedy, is there?
Jochen Heuer
Respected Contributor

Re: exporting DISPLAY

Hi Gary,

it looks as if HP-UX includes a pppd (server daeemon) from 10.30 onward. Have a look at these documents:

http://www4.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000066028178
http://www4.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000062952526 (pppd)

Good luck!

Jochen
Well, yeah ... I suppose there's no point in getting greedy, is there?
Jochen Heuer
Respected Contributor

Re: exporting DISPLAY

Me again ... :-)

Sometimes you don't have to look that far away. Search www.docs.hp.com for 'pppd' and voila:

http://www.docs.hp.com/hpux/onlinedocs/B2355-90137/B2355-90137.html (Installing and Administering PPP)

Regards,

Jochen
Well, yeah ... I suppose there's no point in getting greedy, is there?
Jeff Schussele
Honored Contributor

Re: exporting DISPLAY

Hi Gary,

If I understand your question correctly, I don't think you're going to be able to do X through the console port. You *won't* have an IP from the console - you're just /dev/console & because it's a terminal, the termcap for the term type announced probably won't support graphics - let alone X.
If you need to use dialup (PAINFULLY slow thru a modem) - you'll have to use the modem port (if avail) or a mux port & use PPP or SLIP.

I would never advise anyone to use the console port for ANYTHING other than console access - big security hole.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Fred.Wu
Frequent Advisor

Re: exporting DISPLAY

If someone dial up to your server with a modem, you cannot get any IP information from the remote client,because it's not a TCP/IP connection ,but a PPP instead.
fred
Rajeev  Shukla
Honored Contributor

Re: exporting DISPLAY

The best way for you would be to ask the user to dial into your network(which might use a RAS ) this will return the user an IP adress and then ask him to do an Telnet to the HP server you now got an IP which you can check using who -R|grep
you can then export the display to that IP.

Rajeev