Linux - NewbieThis forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Here is my issue in short. I am looking to run a Java program which uses the Swing libraries and therefor requires a connection to X server. The trick is that I'm trying to run this programming through SSH.
I have tried using Xvfb(X Virtual Frame Buffer) to run my program however it simply doesn't work in Xvfb(seems to work but doesn't produce the output I'm looking for).
If I log into the server using the Grub login interface(what you would normally see at system boot up) and then instead of logging out I "Switch User", my program runs successfully through SSH. In SSH I set the DISPLAY(:0.0) which was initiated(authenticated??) from my Grub session and the program runs just as expected.
I suspect it might have something to do with my xauth cookie but I can't seem to grasp the concept from documents around the web.
I should note that the error I get when trying to use DISPLAY :0.0 from SSH when completely logged out is:
Quote:
No protocol specified
java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
My question is: How can I simulate(or initiate) the action of logging into the computer as if you were in front of the screen and then "Switching Users"?
Thanks in advance.
My system is:
Ubuntu Server 9.04
Linux version 2.6.28-14-server
What you are trying to do should "just work" if you run 'ssh -X servername' from another system running X. If you are trying to do this from a Windows system, you will need to install an X server (search for cygwin on Google) to get it to work. As far as "Grub login interface" goes, this is a completely nonsensical expression. I have no idea what you are talking about, and I'd wager nobody else does either. I'm guessing you mean you are logging into the command-line interface (or CLI), but I'm only guessing. I also have no idea what you mean by "switching users" from a CLI perspective however. I'd love to help you, but I'll need clarification and more details.
Let us know,
Forrestt
p.s. after your edit, there is a bit more clarity, however not totally sure. Try running "ssh -X servername" and then don't do anything to your DISPLAY variable, but just run your app.
forrestt, that's for your reply. I guess I forgot to mention that I'm trying to get this to run without X on the client side. It will be run from a PHP script that connects to the server through SSH. PHP doesn't run X so I need this to run completely separate from X on the Client even though the program requires it. This is where Xvfb came in.
Think of it this way. 2 computers total. 1 computer without X connecting through SSH(call it Client) and the physical screen attached to the server(call it Server). Here are the steps to get it to work:
1. Log into the Server from the physical screen.
2. Log into the Server from the Client.
3. Set DISPLAY to :0.0 from the Client.
4. Run the Java program from the Client.
I guess noting that I "Switched Users" on the Server from the physical screen in the Grub environment was unnecessary. The point was that I can't completely log off the Grub environment.
The way it does NOT work:
1. Log into the Server from the physical screen.
2. Log into the Server from the Client.
3. Log OFF the Server from the physical screen.
4. Set DISPLAY to :0.0 from the Client.
5. Run the Java program from the Client.
Using these 5 steps produces the error I quoted in my post.
OK, I think I understand what you are saying now. I also think you understand what the problem is. The confusion I was having is based on the terminology you are using. Perhaps you don't mean Grub but rather the Gnome environment? Anyway, yes, you have to have an active X session in order to open a window. I'm not familiar with any way to achieve this without Xvfb or having a system that boots into an active X session without needing to log in. Do you really have to get the info you are looking for from a GUI, or are you just doing that because you know that it works? Perhaps if you tell us the info you are looking for, we can give you an alternative way to get the same info without running a GUI app.
Thanks again forrestt, I appreciate your help. Indeed I did mean Gnome. Sorry about that.
I'm porting a macro script written for the program ImageJ to perform convolution on an image and create a matrix of image representing the view of scanning electron microscopes. Not easy to find the software to do this. Luckily the person who programmed the macro did it within software that can be run from the command line. However, ImageJ has been known to have issues with running headless. Even though they provide the option to run "headless" the libraries for their GUI are still evoked. Bummer.
You may be able to achieve this by running an X Windows Server locally
the free one for Windows that I know of is Xming (google it)
forrestt was right about ssh -X (or you can get the same effect in putty by changing some settings)
However not every server is set up for this, you may need to edit /etc/ssh/ssh_config
and add 'ForwardX11 yes' to the list and restart the sshd.
forrestt was also right in saying when you login using ssh -X
do NOT replace the Display variable!
it gets set differently then if you login from the physical screen, even if the physical screen is not logged in to an X session
Just a thought - never tried this - but look at the various CLI browser implementations to see how they manage a display without an X-server. Also, I think I recall a thread a couple of months ago about a CLI X-sever as well.
You may be able to achieve this by running an X Windows Server locally
the free one for Windows that I know of is Xming (google it)
forrestt was right about ssh -X (or you can get the same effect in putty by changing some settings)
However not every server is set up for this, you may need to edit /etc/ssh/ssh_config
and add 'ForwardX11 yes' to the list and restart the sshd.
forrestt was also right in saying when you login using ssh -X
do NOT replace the Display variable!
it gets set differently then if you login from the physical screen, even if the physical screen is not logged in to an X session
sorry if this did not help
Good Luck
Thanks for your reply. I think you're missing the goal however. Windows and Xming can not be involved. The connection to the server is being made with PHP. As far as I know there is no X Windows implementation for PHP.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.