Um.. I'm not sure it's a scriptfile he's having a problem with. vnc comes as a package in Redhat (compiled binary) and all set up to go.
It does however, require a bit of reading of the manual.
I'm not sure why you're su'ing to various users.
However, man vncserver says this :
:number
The display number to use. If omitted, the next free display number is used.
so, you can do this in your startup script :
vncserver :1
vncserver :2
Looking further I see a file /etc/sysconfig/vncservers :
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the line below to start a VNC server on display :1
# as my 'myusername' (adjust this to your own). You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see
# <URL:
http://www.uk.research.att.com/vnc/sshvnc.html>.
# VNCSERVERS="1:myusername"
One would imagine you'd need to set up your displays like :
VNCSERVERS="1:fred"
VNCSERVERS="2:barney"
and man vncpasswd.
Looking at your script, and looking at how the above works it seems like you're running the same instance of a single vnc server twice... the first will be replaced with the second...
Looking at 'man vncpasswd' I can see why you're su'ing to two different users. Perhaps you could set up a file to store your passwords make it root writable and have both passwords in the same place.
Slick.