Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I'm having a problem with an application that I inherited. The application is essentially a custom-made print daemon that converts incoming files to PCL and submits them to a printer. The application is called by a bash script that polls an incoming directory and launches the application based on the incoming file type.
I've got the script loaded into crontab.
Crontab calls the script, which polls the directory and calls the application. Based on testing, if I manually call the script from the console, it works fine. If I modify the crontab from the console and log off, it seems to work fine. But if I call the application from a SSH session, or if I modify the crontab from an SSH session, I get the following error:
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
<application>: cannot connect to X server :0.0
I've been able to deduce that the application wants to run as if at the console. In the script, I can see that the DISPLAY variable is set to :0.0 in an attempt to get this done, but it apparently isn't happening.
I've tried commenting out the "export DISPLAY=" statement, and I get
<application>: cannot connect to X server
(no Xlib lines, no port spedified by the application error line.)
What's going on here? How do I get this to work consistently without having to launch it from the console? In theory, I'm deploying this to several remote sites and I won't have the ability to launch from the console.
Any help would be greatly apprecaited. Thanks in advance.
(I do have contacts with the people who wrote this app, and I'm following up with them, but they appear to be application programmers and don't seem to have a much firmer grasp of X than I do. If they come through with an answer, I'll post it.)
Here's some additional information based on your post and further testing:
For any other application, opening an X window isn't a problem. We're connecting to the server (Redhat Enterprise Linux 3.0, btw) using putty with X tunnelling enabled, and running winaXe on our windows machines to run X sessions locally. For example, I can ssh to the server, type mozilla at the prompt, and the browser opens on my machine. (BTW, if you use the -X switch, you don't have to change the DISPLAY variable; ssh handles this for you. At least that's what I've read and it works for me.)
I just finished running a series of tests on the server to figure out what the different scenarios are that result in successful printing and what result in failure. Here's how that turned out:
user logged into console, manually launching script: success
user logged into console, script called via crontab: success
no one logged into console, script called via crontab: failure
The failed scenario resulted in the xlib errors in my initial post. I did not yet run with a different user logged on at the console, but my feeling is that it will fail with anyone other than the app's owner.
So I know it's a problem with the app, and the app developer is looking into it, but what's the problem and can we address it while waiting for a fix from the developer?
About my tests -- all were conducted with no SSH connections by the app owner. Just wanted to clear that up. Another test for me to conduct is what happens if the app owner is connected via SSH as well as logged on at the console. It's on my list...
Jobs submitted to Cron should not require any user interaction---they should not require any input and should not require use of an X Display.
If the job requires an X-Display then it will fail when one is not available. That is why you get the X connection error if the owner is not logged in at the console when the cron job runs.
The "export DISPLAY=:0.0" in the script tells the app to use the local display. It can only do this if the owner is logged in at the local console.
If the app is non-interactive (and it should be if it is scheduled with Cron) then it should not use the X Display. The correct fix would be to get an update of the application that does not request an X-Display.
As a work-around, if a fix for the app is not available, the owner of the job can run a vncserver using Xvnc. Then set the DISPLAY variable to point to the Xvnc server in the script (for example :1 or :2, depending on which display the vncserver is running on). The Vncserver can be kept running even when the user is not logged on.
Thanks for your post. I've tested your suggestion and it appears to work, giving us a workaround until the problem gets resolved. According to a developer, their executable uses X functionality for other tasks (not what is required for the scripted job), so that's why Xlib is being used. No word yet on whether it can be bypassed for this scripted task.