QUESTION
I have installed TigerVNC server software to a Ubuntu 18.04 guest machine running in VMware Workstation.
I can VNC into (i.e. use a VNC viewer to see) the guest machine just fine after manually executing the following line in either Terminal or Xterm (of the guest machine):
vncserver :1 -localhost no -geometry 980x700 -depth 32
But running the same line in a script, as follows, gives me only a black screen on the VNC viewer with a dot for a cursor.
#!/bin/bash
vncserver :1 -localhost no -geometry 980x700 -depth 32
What should I do to the script to get it to work (give me a proper VNC screen)?
BACKGROUND
I am new to both Ubuntu and this site. If I am leaving out relevant information, please let me know what it is and I'll update the question with it. For now, I can think of the following.
Not all scripts give me a problem. For example, I use the following just fine (to mount in the Ubuntu guest a Window machine's shared folder).
#!/bin/bash
sudo mount -t cifs -o username=tom,uid=1000,gid=1000 //192.168.0.17/d /home/loom/mnt/summer_d
The following (intended to mount a hard drive) however fails, and I must manually execute the sudo
line in Terminal or Xterm.
#!/bin/bash
sudo mount /dev/sdb1 /home/loom/hdd/hdd5 -o uid=1000,gid=1000,utf8,dmask=027,fmask=137
When I execute manually, I am doing so from the same directory as the scripts are located in; so that doesn't seem to be an issue.
When I double-click the script, it loads into Xterm.
Running echo $SHELL
in either Terminal or Xterm gives me /bin/bash
.
As you can see, I have a general problem: Scripts don't reliably work.
Since I see the she-bang line of the script as feeding the other lines to a particular shell and the other lines as entering what I might have manually, I don't see why the same line should work or not depending on how they are entered (manually or through a script).
A great answer would show me how to solve the specific problem with VNC and provide a general explanation of what I may be doing wrong in these scripts. Thanks.