Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SETTING YOUR DISPLAY

Status
Not open for further replies.

johngiggs

Technical User
Oct 30, 2002
492
US
In order to set my display for an X session I have the following commands in a file:

#!/usr/bin/csh

setenv DISPLAY XXX.XXX.XX.XX:0

commands

The only problem is that if I am working from a different workstation, my IP address is obviously different. Is there a command that I can use so that it will automatically detect my IP address and use it to set my display?
 
127.0.0.1 is the loopback IP address of your own machine

setenv DISPLAY 127.0.0.1:0

or maybe
setenv DISPLAY localhost:0

 
No, localhost or 127.0.0.1 is a loopback to itself. That will pop the window up on the remote machine, not on the one he's working from.

I use the following on Solaris 8 with the Korn shell. You might be able to mod it for your purposes...
Code:
#!/bin/ksh

export TTY=$(ps -o tty|uniq|tail -1)
export DISPLAY=$(last -a `whoami`|grep ${TTY}|grep "still logged in"|head -1|awk '{print $10}'):0
This first uses [tt]ps[/tt] to get the TTY of the current process. Then [tt]last[/tt] is used to figure out where you're coming from and build the [tt]DISPLAY[/tt] variable.

Hope this helps.

 
Sorry - mis-read what was trying to be achieved
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top