LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-05-2003, 04:36 AM   #1
Gianni
LQ Newbie
 
Registered: Feb 2003
Posts: 20

Rep: Reputation: 0
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.
 
Old 02-07-2003, 10:08 AM   #2
antken
Member
 
Registered: Nov 2000
Posts: 368

Rep: Reputation: Disabled
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
#
# Description: Starts Vnc server at startup


echo "Starting VNCServer:"
/path/to/vnc/server && echo "Success"

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
 
Old 02-07-2003, 11:41 AM   #3
baldy3105
Member
 
Registered: Jan 2003
Location: Cambridgeshire, UK
Distribution: Mint (Desktop), Debian (Server)
Posts: 891

Rep: Reputation: 184Reputation: 184
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
 
Old 02-10-2003, 05:41 AM   #4
Gianni
LQ Newbie
 
Registered: Feb 2003
Posts: 20

Original Poster
Rep: Reputation: 0
I get syntax error messages when the system is rebooted and it runs that script..


Quote:
Originally posted by baldy3105
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
 
Old 02-10-2003, 05:42 AM   #5
Gianni
LQ Newbie
 
Registered: Feb 2003
Posts: 20

Original Poster
Rep: Reputation: 0
THANKS ! will try it out

Quote:
Originally posted by antken
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
#
# Description: Starts Vnc server at startup


echo "Starting VNCServer:"
/path/to/vnc/server && echo "Success"

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
 
Old 02-10-2003, 06:27 AM   #6
Gianni
LQ Newbie
 
Registered: Feb 2003
Posts: 20

Original Poster
Rep: Reputation: 0
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:
Originally posted by Gianni
THANKS ! will try it out
 
Old 02-10-2003, 06:58 AM   #7
Gianni
LQ Newbie
 
Registered: Feb 2003
Posts: 20

Original Poster
Rep: Reputation: 0
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!
 
Old 02-10-2003, 08:45 AM   #8
antken
Member
 
Registered: Nov 2000
Posts: 368

Rep: Reputation: Disabled
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
 
Old 02-10-2003, 08:52 AM   #9
Gianni
LQ Newbie
 
Registered: Feb 2003
Posts: 20

Original Poster
Rep: Reputation: 0
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:
Originally posted by antken
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
 
Old 02-10-2003, 09:04 AM   #10
antken
Member
 
Registered: Nov 2000
Posts: 368

Rep: Reputation: Disabled
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
#
# Description: Starts Vnc server at startup

echo "Starting VNCServer:"

PATH={your paths here include one for the location of the vnc files }

export PATH

/path/to/vnc/server && echo "Success"

hope this helps!

 
Old 02-10-2003, 09:09 AM   #11
Gianni
LQ Newbie
 
Registered: Feb 2003
Posts: 20

Original Poster
Rep: Reputation: 0
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:
Originally posted by antken
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
#
# Description: Starts Vnc server at startup

echo "Starting VNCServer:"

PATH={your paths here include one for the location of the vnc files }

export PATH

/path/to/vnc/server && echo "Success"

hope this helps!

 
Old 02-10-2003, 09:32 AM   #12
Gianni
LQ Newbie
 
Registered: Feb 2003
Posts: 20

Original Poster
Rep: Reputation: 0
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 ?
 
Old 02-10-2003, 09:57 AM   #13
antken
Member
 
Registered: Nov 2000
Posts: 368

Rep: Reputation: Disabled
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic Startup of Apache m2azer Linux - General 6 09-20-2004 07:39 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
How to do automatic ISP sign-on at startup? KlaymenDK Linux - Networking 3 10-10-2003 11:42 AM
gui startup--automatic hpglow Linux - Newbie 3 07-22-2003 12:07 PM
Automatic Startup script for Firewall Robertb Linux - General 0 03-27-2001 10:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration