pjc123
Posts: 921
Joined: Thu Mar 29, 2012 3:37 pm

Can not set up VNC server to start at bootup (solved)

Mon Jun 25, 2012 8:13 pm

I am trying to set up tightvnc to automatically start at boot on my pi so I can remove the keyboard and mouse and have an available usb port to set up a wifi device.

I am following the instructions here:

http://elinux.org/RPi_VNC_Server

and I can access the pi from Windows 7 without any problems.

However, when I set it up so that the tightvnc server starts at boot on the pi it produces FAIL error messages during the boot process. So I then manually ran the script that starts vnc via the command "etc/init.d/vncboot start" to see what was going on; I see that text is magically getting inserted into the shell script commands and is messing up the expected results (the text 302\240). Note: I did not test this with the original Debian version and am running the latest wheezy version, so I do not know if the problem is version related.

HERE IS THE SCRIPT:

### BEGIN INIT INFO
# Provides: vncboot
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC Server at boot time
# Description: Start VNC Server at boot time.
### END INIT INFO

#! /bin/sh
# /etc/init.d/vncboot

USER=root
HOME=/root

export USER HOME

case "$1" in
start)
echo "Starting VNC Server"
#Insert your favoured settings for a VNC session
/usr/bin/vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565
;;

stop)
echo "Stopping VNC Server"
/usr/bin/vncserver -kill :1
;;

*)
echo "Usage: /etc/init.d/vncboot {start|stop}"
exit 1
;;
esac

exit 0



HERE IS THE OUTPUT:
./vncboot: line 17: $'export\302\240USER\302\240HOME': command not found
./vncboot: line 19: $'case\302\240start\302\240in': command not found
./vncboot: line 20: syntax error near unexpected token `)'
./vncboot: line 20: ` start)'
My Raspberry Pi Project Page:

https://www.flaminghellmet.com/launch/

emg
Posts: 88
Joined: Wed Jan 11, 2012 11:01 pm

Re: Can not set up VNC server to start at bootup

Tue Jun 26, 2012 12:57 am

Don't know if you want to try another VNC, but I use x11vnc and have lxde autostart it. I found x11vnc was better for me as I wanted to access the same session as being displayed via HDMI (console 0). Plus, it supports UVNC and TightVNC file transfer.

steps:
install and set password
- sudo apt-get install x11vnc
- x11vnc -storepasswd

create autostart entry

- cd .config
- mkdir autostart
- cd autostart
- nano x11vnc.desktop
- paste following text:

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=X11VNC
Comment=
Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer
StartupNotify=false
Terminal=false
Hidden=false

- save and exit (Ctrl-X, Y, <Enter>)

This start x11vnc when lxde starts.

pjc123
Posts: 921
Joined: Thu Mar 29, 2012 3:37 pm

Re: Can not set up VNC server to start at bootup

Tue Jun 26, 2012 11:28 am

emg

Thanks, I might give that a try. I am finding multiple bugs in the program that was listed on elinux; I realize that it is a first draft, but it is obvious that it was never tested at all. I also tried another script and that didn't work as well, and in fact corrupted my linux install to the point that I have to reimage. I found a third method that does not use the init.d scripts at all and I will try that today. I come from the Red Hat world which uses a different method to write and activate startup scripts, so eventually I will have to read up how it works in debian so I can write my own scripts.
My Raspberry Pi Project Page:

https://www.flaminghellmet.com/launch/

pjc123
Posts: 921
Joined: Thu Mar 29, 2012 3:37 pm

Re: Can not set up VNC server to start at bootup

Tue Jun 26, 2012 3:38 pm

I got tired of messing around with the scripts so for the time being I just:

1) Turn on the pi and give it time to boot up.
2) SSH into the pi using putty.
3) Start up the tightvnc server using a script with the necessary parameters added to the vncserver command.
4) Run the tightvnc viewer from my Windows 7 computer and I am in.
My Raspberry Pi Project Page:

https://www.flaminghellmet.com/launch/

User avatar
geep999
Posts: 28
Joined: Fri May 18, 2012 10:20 pm
Location: East Herts, UK

Re: Can not set up VNC server to start at bootup

Tue Jun 26, 2012 10:17 pm

As an alternative to VNC you could try running an Xserver on Windows and just forwarding X11 to it.
I tried it on Vista (32bit) and it worked just fine.
See this post http://www.raspberrypi.org/phpBB3/viewt ... 2&p=106887
Cheers,
Peter

dktucson
Posts: 36
Joined: Tue Jun 12, 2012 2:57 am

Re: Can not set up VNC server to start at bootup

Wed Jun 27, 2012 3:08 am

I saw the same article at elinux..between that site and another I pieced together this that worked;

### BEGIN INIT INFO
# Provides: vncboot
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC Server at boot time
# Description: Start VNC Server at boot time.
### END INIT INFO

#! /bin/sh
# /etc/init.d/vncboot

USER=root
HOME=/root

export USER HOME

case "$1" in
start)
echo "Starting VNC Server"
#Insert your favoured settings for a VNC session
su - $USER -c "/usr/bin/vncserver :3 -geometry 900x640 -depth 16 -pixelformat rgb565 &" &
 ;;

stop)
echo "Stopping VNC Server"
/usr/bin/vncserver -kill :3
 ;;

*)
echo "Usage: /etc/init.d/vncboot {start|stop}"
exit 1
 ;;
esac

exit 0
________________________End File_______________________________________
I set mine to the :3 as I already had VNC on 2 other machines on ports 5901 5902 and the pi was 5903. The setup drove me nuts for about 2 days.Little quirky syntax snibblets but scratched my head via trial & error and got it to work from boot.

joefly
Posts: 65
Joined: Thu May 31, 2012 4:10 pm

Re: Can not set up VNC server to start at bootup

Sat Jul 07, 2012 4:35 pm

emg wrote:Don't know if you want to try another VNC, but I use x11vnc and have lxde autostart it. I found x11vnc was better for me as I wanted to access the same session as being displayed via HDMI (console 0). Plus, it supports UVNC and TightVNC file transfer.

steps:
install and set password
- sudo apt-get install x11vnc
- x11vnc -storepasswd

create autostart entry

- cd .config
- mkdir autostart
- cd autostart
- nano x11vnc.desktop
- paste following text:

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=X11VNC
Comment=
Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer
StartupNotify=false
Terminal=false
Hidden=false

- save and exit (Ctrl-X, Y, <Enter>)

This start x11vnc when lxde starts.

Hi Emg, Thanks for your lead. I got x11vnc working but could not get the autostart after lxde. everytime, I create the x11vnc,desktop file and paste as you stated, i confirm the edit by going back in, I reboot, startx...nothing happens, so i check the x11vnc.desktop and the files is there but is empty. I have done this repeatedly, so I am not sure what I am doing wrong.

also, how do I have the raspberry pi boot into startx and ideally i have a python script that I want to run at startup on boot and no monitor.

My goal, is to have the pi be plugged in and run the python script automatically, and occasionally tunnel in to view the status..

thanks for you help.

joefly
Posts: 65
Joined: Thu May 31, 2012 4:10 pm

Re: Can not set up VNC server to start at bootup

Sat Jul 07, 2012 5:27 pm

hi guys, I just ran into this info http://elinux.org/RPi_Debian_Auto_Login

which allows on boot to login and startx

now the question is if I can get x11vnc running automatically after login and startx, can i enter in either of these files

/etc/inittab or /etc/profile??

and how?

npr
Posts: 3
Joined: Tue Jul 24, 2012 8:06 pm

Re: Can not set up VNC server to start at bootup

Tue Jul 24, 2012 9:05 pm

emg wrote:Don't know if you want to try another VNC, but I use x11vnc and have lxde autostart it. I found x11vnc was better for me as I wanted to access the same session as being displayed via HDMI (console 0). Plus, it supports UVNC and TightVNC file transfer.

steps:
install and set password
- sudo apt-get install x11vnc
- x11vnc -storepasswd

create autostart entry

- cd .config
- mkdir autostart
- cd autostart
- nano x11vnc.desktop
- paste following text:

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=X11VNC
Comment=
Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer
StartupNotify=false
Terminal=false
Hidden=false

- save and exit (Ctrl-X, Y, <Enter>)

This start x11vnc when lxde starts.
I've tried to follow this, but being new to linux I've got hopelessly lost.

I've installed x11vnc ok but am unable to run it. tried following the above instructions but there's no ".config" directory in my RPi.

Any help will be much appreciated.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 15100
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Can not set up VNC server to start at bootup

Tue Jul 24, 2012 9:21 pm

In unix/linux systems files/directories can be made invisible by preceding them with a dot, so .config
in this case (because of the change directory "CD" command preceding it) is an invisible directory called "config".

npr
Posts: 3
Joined: Tue Jul 24, 2012 8:06 pm

Re: Can not set up VNC server to start at bootup

Tue Jul 24, 2012 10:34 pm

Thanks,

Tried cd /.config
and got in to the directory this time -- great :)
Used mkdir autostart
"ls" showed the new directory had been created.

But:
cd /autostart gave the error "No such file or directory"

So I went back to cd / and now I can not get to the config directory -- error "No such file or directory"

I had no problem getting tightvnc to work but needed to see the hdmi screen so really need x11vnc.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2876
Joined: Sat Mar 03, 2012 11:57 am
Location: UK

Re: Can not set up VNC server to start at bootup

Wed Jul 25, 2012 6:20 am

Stewart Watkiss shows you how to do what the OP wants right here. I've tried it on Wheezy beta and Raspbian and it works an absolute treat...
http://www.penguintutor.com/linux/tightvnc

Video to prove it of me playing Chuckie Egg on spectrum emulator through tightvnc
http://raspi.tv/2012/install-and-use-ti ... oid-or-ios
Alex Eames RasPi.TV, RasP.iO

pjc123
Posts: 921
Joined: Thu Mar 29, 2012 3:37 pm

Re: Can not set up VNC server to start at bootup

Wed Jul 25, 2012 6:05 pm

alexeames wrote:Stewart Watkiss shows you how to do what the OP wants right here. I've tried it on Wheezy beta and Raspbian and it works an absolute treat...
http://www.penguintutor.com/linux/tightvnc

Video to prove it of me playing Chuckie Egg on spectrum emulator through tightvnc
http://raspi.tv/2012/install-and-use-ti ... oid-or-ios
YAAAAAAAH ! That's interesting, exactly 1 month from the date of my original post and a working script. Thank you muchly alexeames for that url. Not only that, but the SSH tunnel is the other thing I wanted to set up and that also works; I have verified that everything is encrypted by running Wireshark. As far as I am concerned my original post is marked as solved.
My Raspberry Pi Project Page:

https://www.flaminghellmet.com/launch/

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2876
Joined: Sat Mar 03, 2012 11:57 am
Location: UK

Re: Can not set up VNC server to start at bootup

Wed Jul 25, 2012 7:28 pm

LOL Stewart published that page on 27th June, 2 days after your OP. :shock: :lol:

Glad to have been of use. :idea:
Alex Eames RasPi.TV, RasP.iO

pjc123
Posts: 921
Joined: Thu Mar 29, 2012 3:37 pm

Re: Can not set up VNC server to start at bootup

Wed Jul 25, 2012 7:36 pm

alexeames wrote:LOL Stewart published that page on 27th June, 2 days after your OP. :shock: :lol:

Glad to have been of use. :idea:
Damn, and I thought I was such a Google expert.
My Raspberry Pi Project Page:

https://www.flaminghellmet.com/launch/

blobert123
Posts: 13
Joined: Wed May 23, 2012 6:48 pm

Re: Can not set up VNC server to start at bootup

Thu Jul 26, 2012 12:11 am

hi
noticed your initial script for starting vncserver is the one i use atm without any hitches. though i was wondering how to get it to boot in the pi username instead of root. tried changing USER: to pi
and then HOME to /usr but that stopped it from working. any ideas ?

ps i run the raspbian image released officially (recommended version)

pjc123
Posts: 921
Joined: Thu Mar 29, 2012 3:37 pm

Re: Can not set up VNC server to start at bootup

Thu Jul 26, 2012 1:17 am

blobert123 wrote:hi
noticed your initial script for starting vncserver is the one i use atm without any hitches. though i was wondering how to get it to boot in the pi username instead of root. tried changing USER: to pi
and then HOME to /usr but that stopped it from working. any ideas ?

ps i run the raspbian image released officially (recommended version)
I am not sure how their script works, but in Linux the following is how the home directories are set up by default:

root (root is different for security reasons)
home= /root

pi
home=/home/pi

if you add another user for instance "bob"
home=/home/bob

To see that this is indeed true, log in as either root or pi and type the command pwd (Which stands for present working directory) and it will show you the paths that I have indicated above. So in other words, your HOME setting for pi should be /home/pi not /usr.
My Raspberry Pi Project Page:

https://www.flaminghellmet.com/launch/

npr
Posts: 3
Joined: Tue Jul 24, 2012 8:06 pm

Re: Can not set up VNC server to start at bootup (solved)

Thu Jul 26, 2012 6:49 pm

I've given up on trying to get x11vnc to work so have gone back to tightvnc using the script from here http://www.penguintutor.com/linux/tightvnc

When I connect using port 5901 I need to supply a password as expected.
But if I use port 5900 or 5902 then I connect without being ask for the password. I'm happy that my router will stop any connection attempts from the internet, but surely this is not right.
Is there a way to make connections to all ports require a password?

Acuario
Posts: 3
Joined: Sat Jul 07, 2012 8:39 pm
Location: Tortosa, Costa Dorada, Spain

Re: Can not set up VNC server to start at bootup (solved)

Thu Aug 16, 2012 12:16 pm

x11vnc works perfectly for me and loads on bootup following the instructions above.

The only comment I would make is that if you don't run the x11vnc -storepasswd command to set a password then it will not start up on reboot. Setting a password and it works perfectly.
MK14>ZX80>ZX81>Atom>PC+PIC>Pi

vinntec
Posts: 152
Joined: Thu Aug 02, 2012 9:37 am
Location: Basingstoke, UK

Re: Can not set up VNC server to start at bootup

Thu Aug 16, 2012 1:28 pm

pjc123 wrote:As far as I am concerned my original post is marked as solved.
Hi pjc123, I am probably being dozey, but how do you mark a topic as solved? Peter

pjc123
Posts: 921
Joined: Thu Mar 29, 2012 3:37 pm

Re: Can not set up VNC server to start at bootup (solved)

Thu Aug 16, 2012 1:54 pm

You are not being dozey. The administrator marked it as solved after reading my post. I don't know if this is how it works with bulletin boards in general as this is the method I have used in the past on other boards to list a problem as solved. If there was an administrator or user settable option so the user who made the post was able to mark it as solved it would certainly be a welcome addition. I would think that it would remove some workload off of the administrator as well, but maybe there are other problems associated with that.
My Raspberry Pi Project Page:

https://www.flaminghellmet.com/launch/

Foxstele
Posts: 3
Joined: Mon Aug 20, 2012 12:57 am

Re: Can not set up VNC server to start at bootup (solved)

Mon Aug 20, 2012 10:54 am

Just posting this for anyone else that finds this thread and the above instructions are not working. I had a heck of a time getting this to work. After about an hour of beating my head against a wall I found the answer was through simplification:

if you use emg's solution change the contents of the x11vnc.desktop to:

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=X11VNC
Comment=
Exec=x11vnc 
StartupNotify=false
Terminal=false
Hidden=false
all the switches on the end of the Exec= line are apparently unnecessary. All I know is get rid of the switches and it works.

lines
Posts: 7
Joined: Fri Aug 24, 2012 8:48 pm
Location: DE

Re: Can not set up VNC server to start at bootup (solved)

Sat Aug 25, 2012 12:31 am

Foxstele wrote: all the switches on the end of the Exec= line are apparently unnecessary. All I know is get rid of the switches and it works.
Well.. they are working and quite helpful for me.
Nevertheless, i had to use "-share" instead of "-forever" in my case. Apparently my viewer (KRDC) does not really disconnect the session. It always failed when I tried to reconnect, even with the "-forever" option. With the option "-share", it works fine for me.

Kaspaas
Posts: 26
Joined: Fri Apr 13, 2012 9:54 am

Re: Can not set up VNC server to start at bootup (solved)

Thu Dec 27, 2012 3:03 pm

Is there a way to add the transfer of Sound?

I would love to hear sound to the video I'm playing :)

duckymajor
Posts: 1
Joined: Sun Dec 30, 2012 7:18 pm

Re: Can not set up VNC server to start at bootup (solved)

Sun Dec 30, 2012 7:21 pm

Hi,

Thanks for this post - very helpful.

I have it all running but I cannot seem to get it to access the same port as my HDMI connection so I can control the pi remotely. I can connect to port 0 i.e. [ip_address]:0 ut it still seems to be starting a seperate session. This was validated by going to teminal and typing [who].

Any help would be appreciated.

Thanks,

Danny

Return to “Troubleshooting”