I'm on an Ubuntu system which has a touchscreen set up on display :0.
I wanted to be able to control this touchscreen remotely from Windows, so I set up x11vnc. It works great. But here's the setup:
I have two users (excluding root). One restricted user (basically no permissions, and no password) who logs in automatically to the touchscreen, and one fully configured user with a complex password, sudo permission, etc. I only really care about starting x11vnc when the restricted user logs in (touchscreen becomes active), so I put the command
x11vnc -loop &
at the end of the file /home/restricted/.profile
. Works fine. Note, however, that it has to be a background process because there's other commands that this user has to run (hidden from the human user) later on.
The problem I'm having is that x11vnc is very noisy with its output. Especially if you don't use a password (which I don't), and it's a loop so it just keeps on repeating. Usually this wouldn't be an issue, but not only is redirecting the output to /dev/null not working (explained below), but the output is appearing on the other user's terminal when I log in via ssh to it (which is really annoying because I use that account for maintenance and its impossible to do anything when your screen is being filled with output of some background process. Here's an example of the output I get:
--- x11vnc loop: 1 ---
--- x11vnc loop: waiting for: 1551
###############################################################
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
#@ @#
#@ ** WARNING ** WARNING ** WARNING ** WARNING ** @#
#@ @#
#@ YOU ARE RUNNING X11VNC WITHOUT A PASSWORD!! @#
#@ @#
#@ This means anyone with network access to this computer @#
#@ may be able to view and control your desktop. @#
#@ @#
#@ >>> If you did not mean to do this Press CTRL-C now!! , -OR- set and export your $DISPLAY
environment variable to refer to the display of the desired X server.
- Usually the display is simply ":0" (in fact x11vnc uses this if you forget
to specify it), but in some multi-user situations it could be ":1", ":2",
or even ":137". Ask your administrator or a guru if you are having
difficulty determining what your X DISPLAY is.
** Next, you need to have sufficient permissions (Xauthority)
to connect to the X DISPLAY. Here are some Tips:
- Often, you just need to run x11vnc as the user logged into the X session.
So make sure to be that user when you type x11vnc.
- Being root is usually not enough because the incorrect MIT-MAGIC-COOKIE
file may be accessed. The cookie file contains the secret key that
allows x11vnc to connect to the desired X DISPLAY.
- You can explicitly indicate which MIT-MAGIC-COOKIE file should be used
by the -auth option, e.g.:
x11vnc -auth /home/someuser/.Xauthority -display :0
x11vnc -auth /tmp/.gdmzndVlR -display :0
you must have read permission for the auth file.
See also '-auth guess' and '-findauth' discussed below.
** If NO ONE is logged into an X session yet, but there is a greeter login
program like "gdm", "kdm", "xdm", or "dtlogin" running, you will need
to find and use the raw display manager MIT-MAGIC-COOKIE file.
Some examples for various display managers:
gdm: -auth /var/gdm/:0.Xauth
-auth /var/lib/gdm/:0.Xauth
kdm: -auth /var/lib/kdm/A:0-crWk72
-auth /var/run/xauth/A:0-crWk72
xdm: -auth /var/lib/xdm/authdir/authfiles/A:0-XQvaJk
dtlogin: -auth /var/dt/A:0-UgaaXa
Sometimes the command "ps wwwwaux | grep auth" can reveal the file location.
Starting with x11vnc 0.9.9 you can have it try to guess by using:
-auth guess
(see also the x11vnc -findauth option.)
Only root will have read permission for the file, and so x11vnc must be run
as root (or copy it). The random characters in the filenames will of course
change and the directory the cookie file resides in is system dependent.
See also: http://www.karlrunge.com/x11vnc/faq.html
--- x11vnc loop: sleeping 2000 ms ---
--- x11vnc loop: 2 ---
And that just repeats on and on.
It's yelling at me about not being able to open the display, but it works. I'm guessing this is because the restricted user already ran this command and it connected fine, but now this user is trying to do so as well, so it can't connect.
Why is this happening? There's clearly some hole in my understanding. Here are the different things I tried:
---
**Redirecting output to /dev/null**
In the same place, /home/restricted/.profile
I tried replacing the existing command x11vnc -loop &
with x11vnc -loop > /dev/null 2>&1 &
.
This had zero effect, output was still on other user's terminal and (obviously) didn't go away.
---
**Running command with nohup**
Again in /home/restricted/.profile
, I tried replacing the existing command x11vnc -loop &
with nohup x11vnc -loop &
.
Once again, this had no effect at all. Output was still there. Nohup didn't even create a nohup.out file. At least, I couldn't find it.
For sake of completion, I also tried nohup x11vnc -loop > /dev/null 2>&1 &
again, nothing changed.
---
**Starting x11vnc as a daemon**
Here, I started realizing that I was doing something wrong. I figured that maybe it was because /home/restricted/.profile
was the wrong place to put this kind of thing. So I made a script in /etc/init.d
to be run on boot and made the link with update-rc.d
following the example of the skeleton file.
Once again, x11vnc worked, but the output was on all my terminals.
---
**Starting x11vnc in screen**
My last attempt at fixing this thing was throwing the command in a screen session. Screen usually fixes problems like this for me... But not this time.
In /home/restricted/.profile
, I replaced x11vnc -loop &
with screen -d -R x11vnc x11vnc -loop
This time, x11vnc didn't work anymore (wasn't able to connect via Windows client), but the output was STILL on all the terminals.
---
Again, clearly there's something I'm not understanding either about x11vnc or spawning a process on boot.
As you might have been able to tell from the above, I've been at this troubleshooting for a while and can't find anything else on the web about this. So help here would be awesome. Thanks in advance.
Asked by MD-7
(193 rep)
May 20, 2016, 03:28 PM
Last activity: Apr 26, 2025, 04:05 PM
Last activity: Apr 26, 2025, 04:05 PM