Score:0

TigerVNC gives black screen when started by script

mm flag

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.

Score:1
us flag

where did you put the scripts in question? They must be in a directory that is part of the $PATH environment variables of your machine. You can find it with this command

 echo $PATH

which should return something like this

echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

and if they are in one of these folders you should also check that your scripts are executable.

If it is not the case you have to move to the folder, open the terminal and launch

sudo chmod +x script_name
Catomic avatar
mm flag
Thanks. I tried. I cannot move or copy any script into any directory in $PATH. I may have to acquire permission or try as superuser? Anyway, there are many scripts in the present location that work fine. How can they work without being in a $PATH directory?
lejurassien avatar
us flag
`sudo mv /the_script /the_destination ` and also check if they are executable and also the user and group.
lejurassien avatar
us flag
I opt for another solution to launch x11vnc. Using the application menu at startup and adding the start of x11vnc with this [Imgur1](https://i.imgur.com/NcONDOR.jpg) [Imgur2](https://i.imgur.com/u9uYJ9i.jpg) and make sure that the session does not lock otherwise there is a black screen with a dot, which reminds me of your problem, look carefully that your session does not lock
Catomic avatar
mm flag
I did the two things (`mv` to a $PATH location and `chmod`), and the result is: the hard drive mounting script works, but the VNC script still gives me a black screen. Your answer is highly valuable to me on account of the first script. Thanks. I will post another question on how to include a directory in $PATH (to serve as depository for scripts) and whether I could so set the directory that whatever script I create in it already has the `chmod +w` status. Perhaps you will kindly take an interest in the new question too.
lejurassien avatar
us flag
Sorry for the delay, so to add a directory in the $PATH just run this command `export PATH=/home/catomic/work:$PATH` of course the address can be whatever you want /bin/my-scripts which would give `export PATH=/bin/my-scripts:$PATH` And normally the scripts that you will put in this directory will be executable as long as you have the good rights for the directory and for the scripts. I hope this is what you are asking my english is soo bad
lejurassien avatar
us flag
But there is still one thing, it is not permanent, that is to say at reboot the added path will have disappeared so that it becomes permanent once the tests are conclusive it is necessary to edit the .bashrc or the .profile. I put you a link that explains all this and in your language https://www.howtogeek.com/658904/how-to-add-a-directory-to-your-path-in-linux/
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.