VNC automatic startup script
Hi all
I am using SUSE 7.2 and was wondering if anyone could help with a script to start vncserver automatically when the machie is booted / rebooted ? I have tried one but it doesn't seem to work. Also most of the references are to Red HAt and some of the files they talk about are not in the same location. thanks gianni ps. Yep, I am only beginning to use Linux. |
hi,
i had this problem a couple of months ago, basically you need to add it to your start up, or init scripts as they are some times called to do this: find out what run level your computer starts in you can do this by entering the command: cat /etc/inittab |grep default it will then return a few lines the last one it returns should be something like id:X:initdefault the X represents a number, this number is the runlevel that your computer start in next: jump into the initscripts directory for that run level todo this type : cd /etc/rcX.d ( where X is the default run level ) in this directory are the 'init scripts' that the system runs at startup they generally named in this fashion S**program ( where ** is the number order in which it is loaded ( 0 is first then 1 etc ) ) S means start and K means kill ( or to stop the process ) then use vi or your favorite text editing program to create the start up script for example: vi S94vncserver now you need to start creating your shell script to start the file, on the very first line you need the shebang, this shebang is a hint to the system of what program is needed to process the script. a shebang line looks like this: #!/bin/sh the #! is the start of the shebang and sets the ball rolling, the '/bin/sh' gives refrence to sh, a command interpriter that most linux boxes have. now you need to put your script together you can use normal command line options in this file ( as far as i know ) for example: Code:
#!/bin/sh the above is just basic script, its probably best if you look up using google 'linux shell scripts' and learning it properly. Plus look at some of your existing startup scripts and you will learn how to do one where you can type vncserver start or vncserver stop dont forget to set the exeecute permission on the file you create or you may have problems i would recomend starting vncserver last this gives the system the chance to load any program dependancys, like vnc needs network to be started first in order to function i hope this helps :) note: if there is any one else out there at can do this in a better way i really would like to hear it please |
There was info on this on the VNC homepage. You can start it using inetd apparently, also there is some sort of RC script info here - http://www.mpthrill.com/vncrc
|
I get syntax error messages when the system is rebooted and it runs that script..
Quote:
|
THANKS ! will try it out
Quote:
|
ok so with that simple script you gave me, I get and file or directory doesn't exits error.
I have used whereis to fin vncserver and get 2 locations /usr/X11R6/binvncserver and /usr/X11/binvncserver I have tried both with the same error message... Quote:
|
next error message
:)
ok I think I have most of it working, except I get this now: couldn't find "xauth" on your PATH trawling google as we speak but if you can help , would be great! |
right i think that because the PATH is not set untill you logon
if you logon and look in your home dir for a file called: .bash_profile edit this file ( again using your favorite text editor ) some where in there there will be a line that says: PATH=/bin:/sbin or similar copy this line out and paste it into your vnc start script ( above the execution command for vnc ( PATH needs to be defined before the vnc execute command ) ) then under the PATH= line type: export PATH that then activates the PATH varible for use in the rest of the script hope this helps |
ok I ssh in and there is no file called .bash_profiel :)
sorry for being such a pain I was reading about adding the path by using PATH=$PATH:{path to be added} can I do it that way ? ps. I am loggin in as root. Quote:
|
yes you could do that although, dont forget that this is at final boot and 9 times out of 10 on most distros do not define PATH until a user logs on
the best way to find out your path is to do the following: logon as a user that can run VNC server successfully when loged on type: echo $PATH it should return a line of stuff like /bin:/sbin:/usr/bin and so on copy this line into your start up script for VNc server ( remember before the vnc server execute command ) then do 'export PATH' directly after it ( with out the quotes ) here is an example of the updated script to include the path statement: Code:
#!/bin/sh hope this helps! :) |
will try that now, thanks!
the thing is I can vnc perfectly if I start it manually via ssh. Just thought I'd try and make it automatic :) being very new to Linux it's quite an experience hehehe thanks again Quote:
|
ok :)
looks like I'm alsmost there... I rebooted the machiine and on restart I get my "starting vnc now" message then the system says that I will need a password for vnc and prompts for one. After a few seconds the systems carries on with the boot as per normal. so almost there but still can't vnc straight in..will I have to include a password somewhere ? |
if you reboot again it should not ask for one
from memory, vnc should store the password in a file its just a case of the system creating a new one hope this helped |
All times are GMT -5. The time now is 12:00 AM. |