3

I would like to run 2 VNCServers from one of my computers. I want one to run the startup commands specified in xstartup, but I want another one to execute different commands. How can this be done? Thanks.

2
  • It would be helpful to understand what you are trying to accomplish or what problem you are running into. My experience has been to simply run vnc from the commandline of the ssh session, and everything seems to work pretty well, even with multiple VNC connections to the box.
    – pcapademic
    Jan 9, 2010 at 8:07
  • I want to give 2 people access to 2 different VNC servers. Each person needs different startup programs. Jan 9, 2010 at 21:30

2 Answers 2

1

You can't directly execute a different xstartup file, but since it's really just a shell script you can accomplish this by building script logic that can figure out whether it is the first or second VNC session.

For example:

#!/bin/sh

# switch on display number for special sessions
[ $DISPLAY == ":1" ] && exec startupOne
[ $DISPLAY == ":2" ] && exec startupTwo

# ... else use the normal vnc xstartup

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
2
  • I'm having some trouble getting this to work. I checked the value of $DISPLAY in my VNCServers, and it's actually ":1.0" and ":2.0" instead. I changed the script to this, but I'm still not seeing the scripts being executed, even if I put the full path to the individual scripts. Jan 10, 2010 at 0:02
  • Are the scripts executable? DO you get any error messages in $HOME/.xsession-errors? Are the scripts found in the current PATH? Perhaps you'll have more success if you use full path spec such as "exec $HOME/.vnc/startupOne". Jan 12, 2010 at 4:11
0

I'm kinda new to messing around in bash scripts but I did have a very similar requirement. General when working on an ipad i wanted a lightweight XCFE, but over LAN I want a full gnome desktop.

I worked around this by creating 2 additional xstartup files xstartup1 & xstartup and then just copying over the xstartup file at run time.

Example script...

#!/bin/sh
vncserver -kill :2
vncserver -kill :1
cp xstartup1 xstartup
vncserver
cp xstartup2 xstartup
vncserver

This should kill off old session if there and then create new sessions accessible on 5901 & 5902 :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .