- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script to export the DISPLAY between two machines
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-10-2006 05:56 AM
тАО04-10-2006 05:56 AM
Script to export the DISPLAY between two machines
I would like to know if any one has an idea how to export (via script) the DISPLAY of machine A to another machine B (using, SSH, Telent or Expect).
Thanks in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-10-2006 06:47 AM
тАО04-10-2006 06:47 AM
Re: Script to export the DISPLAY between two machines
Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-10-2006 06:53 AM
тАО04-10-2006 06:53 AM
Re: Script to export the DISPLAY between two machines
Are you sure ?
Personally, I do not think so..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-10-2006 06:59 AM
тАО04-10-2006 06:59 AM
Re: Script to export the DISPLAY between two machines
What I do, issue the command 'who -um' and this will give a 1 line response. The last field is the IP/host you are coming from.
export DISPLAY=`who -um | awk '{print $NF}'`:0
I put this in the .profile
If it resolves then you get the host name. If you are on a Linux system, the IP address will be enclosed in parenthesis, use the 'tr -d ()' command to get rid of the parenthesis.
All of this is done within the $HOME/.profile so the DISPLAY is set once you log in.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-10-2006 07:04 AM
тАО04-10-2006 07:04 AM
Re: Script to export the DISPLAY between two machines
If the ForwardX11 variable is set to ``yes'' (or, see the description
of the -X and -x options described later) and the user is using X11
(the DISPLAY environment variable is set), the connection to the X11
display is automatically forwarded to the remote side in such a way
that any X11 programs started from the shell (or command) will go
through the encrypted channel, and the connection to the real X server
will be made from the local machine. The user should not manually set
DISPLAY. Forwarding of X11 connections can be configured on the
command line or in configuration files.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-10-2006 07:06 AM
тАО04-10-2006 07:06 AM
Re: Script to export the DISPLAY between two machines
I have machine 1: echo $DISPLAY >> 1.2.3.4 (for instance).
I would like from machine 1 connect via SSH to machine 2 and do: export DISPLAY=1.2.3.4 (export the display of machine 1 to machine2)
BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-10-2006 09:06 AM
тАО04-10-2006 09:06 AM
Re: Script to export the DISPLAY between two machines
This would do the export if you are at display 0 from server one:
ssh server 2:
Execute command:
export DISPLAY=`who -um | awk '{print $8}' | tr -d '()'`:0.0
Test it with:
xclock
But you could enable X-forward in ssh (if you config are at /etc/ssh):
vi /etc/ssh/sshd_config
# X11 tunneling options
X11Forwarding yes
X11DisplayOffset 10
Then restart you sshd deamon on the changed system. You may need to change X11 options on the connecting server as well.
Regards,
Jannik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-10-2006 09:19 AM
тАО04-10-2006 09:19 AM
Re: Script to export the DISPLAY between two machines
In addition the the sshd_config:X11Forwarding yes mentioned in the previous post, ensure the ssh_config:ForwardX11 yes is also set. The one in the sshd_config tells the daemon whether or not it's possible, the one in ssh_config determines whether it's on by default. That can be tweaked by user in a ~/.ssh/config file if needed.
HTH;
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2006 03:23 AM
тАО04-11-2006 03:23 AM
Re: Script to export the DISPLAY between two machines
this is some code of my multi-OS profile concerning the DISPLAY variable. You should run this piece of code only, when you have a tty, so put it in block like
if [ -t 1 ]
then
...
fi
#### START
get_os () { OSs=$1; HOST=$2; OSr=$3 ;}
get_os `uname -snr`
export HOST OSs OSr
if [ -z "$ENVONLY" ] # SGIonly
then
tty=`tty | awk -F/ '{if ($NF ~ "tty") print(substr($NF,4,length($NF)-3))
else print $NF}'`
fi
case $OSs in
HP-UX)
if [ "$tty" = con ]
then remhost=
else remhost=`who am i -R | awk '{print(substr($NF,2,length($NF)-2))}'`
fi
;;
DomainOS)
if [ "$tty" = display ]
then remhost=
else remhost=`who am i | awk "/$tty /"' {print $NF}'`
fi
;;
SUN*)
remhost=`finger -fhmpsw $LOGNAME | awk "/$tty /"' {print $NF}'`
;;
IRIX*) remhost=$REMOTEHOST
;;
Linux) remhost=`who am i | awk '{print(substr($NF,2,length($NF)-2))}'`
;;
SCO*)remhost=`who -mx | awk '{print $NF}'`
;;
*)
remhost=`finger -fhmpsw $LOGNAME | awk "/$tty /"' {print $NF}'`
;;
esac
# post-processing of remhost
case "$remhost" in
'') remhost=localhost
disp=:0.0 ;;
*:0.0) disp=$remhost
remhost=${remhost%:*} ;;
*:*) remhost=${remhost%:*}
disp=$remhost:0.0 ;;
*.*) remhost=${remhost%%.*}
disp=$remhost:0.0 ;;
*) disp=$remhost:0.0 ;;
esac
DISPLAY=${DISPLAY:-$disp}
# or overide:
# DISPLAY=$disp
export DISPLAY
#### FINI
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2006 07:42 AM
тАО04-11-2006 07:42 AM
Re: Script to export the DISPLAY between two machines
I think there are a miss-understanding of the problem. Let me explain you the situation:
1/Server1 (where I am logged as user1) from PC: echo $DISPLAY gives 1.2.3.4:0.0
2/ Server2 (where I would like to connect as user2 via SSH without password and export the display to the same value as server1). Some thing like: export DISPLAY=1.2.3.4:0.0
3/ server1-user1# ssh user2@server2 script
==> So, as user1 at server1, I will connect via SSH to server2 as user 2 (without password) : this step is OK.
Then I would like to export the DISPLAY of server2/user2 to the same value as user1/server1.
Note: 1.2.3.4 may changes depending on the PC I am using.
Hope now it is well explained
Thx in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2006 09:26 AM
тАО04-11-2006 09:26 AM
Re: Script to export the DISPLAY between two machines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2006 09:41 AM
тАО04-11-2006 09:41 AM
Re: Script to export the DISPLAY between two machines
who -u | grep user1 | awk '{print $NF}' | tr -d ()
Parse the relevant info from the connection of user1/server1 and pass that to the export DISPLAY for user2/server2.
Again, this can be included in the .profile so it will execute on login. Can also make it a standalone script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2006 10:13 AM
тАО04-11-2006 10:13 AM
Re: Script to export the DISPLAY between two machines
BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-13-2006 06:53 AM
тАО04-13-2006 06:53 AM
Re: Script to export the DISPLAY between two machines
root pts/1 Apr 13 08:48 0:11 1337 (1.2.3.4)
root pts/2 Apr 13 08:49 0:10 1338 (1.2.3.5)
In this example I have 2 login sessions for root but they have unique IP addresses from where they logged in from.
If you do the command "who -u | awk '{print $NF}' | tr -d ()" then you will get only the IP addresses. Match that up with the PC you are working on (what is IP of the PC you are working on?).
So the result is
1.2.3.4
1.2.3.5
Which IP address are you wanting, export the DISPLAY with that IP.
Works with hostnames as well if you have name resolution