Link to home
Start Free TrialLog in
Avatar of stefanvig
stefanvig

asked on

setting xhost + localhost only through telnet

I have trouble setting xhost + localhost through telnet to a remote RedHat 5 machine.
I can manually log in to the machine and make this setting, but I need to do this through either a shell or a perl script (I need this for some automated testing).
I looked at some previous posts, and I tried some of the suggestions but they all seem to suppose that you will log in to the machine manually. But I only log in to the machine through a perl script using telnet, make some settings, like adding it to a grid, and then the grid will send out some applications to it. These applications won't see the xhost + localhost only if I do it manually on the machine.
If I manually log in to the machine, then all I need to do is to do xhost + localhost , and then export DISPLAY :0 from my script and it all works.
However I just can't set xhost + localhost from the script.
I tried setting it from $HOME/.Xclients and /etc/X0.hosts but it didn't work.

Please let me know if you have any suggestions.

Thanks,
Stefan
Avatar of yuzh
yuzh

if you want to run application from a remote machine and display in your local workstation. You need to set "xhost +" in your local  machine, not the remote machine.
the script you run in the remote machine you need to set the DISPLAY before running the app, please have a look at the answer in http:Q_22779458.html and http:Q_20365626.html to learn how to set DISPLAY in a script.
BTW, telnet is not secure, consider use ssh (secure shell) with X forwading enable to do the job,
you can setup ssh login without password (a lot of examples at EE) or install expect and expect script to handle the login and password, and you don't need to worry about set DISPLAY.
Avatar of stefanvig

ASKER

Thanks for your comments.
This is a grid of 5 to 10 virtual RedHat5 machines. I choose telnet, only because it is easier to use it with a Perl script that I run on a windows machine. I want to have applications running on all these machines in parallel. So I don't need to see the display, I just need a display set up anywhere so the application would run.
If I set the DISPLAY to the same machine (:0) it worked, but I had to manually log in to each machine and set xhost + or xhost + localhost.
I need a way to set xhost + localhost from a script, without manually logging in to all these machines.
Sorry I didn't mention that I only have a Windows local machine, that is why I can't set the xhost on my machine.
If you want to display the app in the remote machine, you have to have someone login (or stay login the remote and run "xhost +".
also please read:
http://docs.sun.com/app/docs/doc/806-7612/6jgfmsvrp?a=view#networkapp-96940 
Hi,
to enable a name by default, this name can be defined in the /etc/X?.hosts file of the remote system, where ? is the display number to which you enable access.

To enable localhost:0 create a file /etc/X0.hosts at the target machine containing "localhost" or "127.0.0.1"
wmp
I tried writing 'localhost' to /etc/X0.hosts and that worked if I manually log in to the machine. Otherwise it didn't help.

So there is no way for a machine to accept a display if you are not logged in to it? I just need to display somewhere (anywhere) so that my application would run.

The workaround I have is that I need an extra machine that I stay logged on (and run xhost + on it) just to be able to display somewhere from all the grid machines. But it would be nice to avoid needing an extra machine just for display purposes, and be able to display on the machines that run the applications themselves. The applications run on these machines as grid jobs, and the login issue comes in  I am not logged in to these machines when they execute jobs.
ASKER CERTIFIED SOLUTION
Avatar of yuzh
yuzh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial