1

Background: I SSH into my Linux machine via Putty on my Windows machine. I am running VcXsrv on Windows and forwarding X over SSH. This is all working as expected.

I am running into issues opening gnome-terminal on the new display when executing the commands through a bash script.

When I execute these commands directly on the console, the new terminal server starts and I am able to start gnome terminal sessions that connect to the server.

$ /usr/libexec/gnome-terminal-server --app-id my.foo &
[1] 29553
$ gnome-terminal --app-id my.foo
$

However, when I place the same commands into a shell script, I get the following error:

contents of startGnomeTerm.sh

#!/bin/bash
/usr/libexec/gnome-terminal-server --app-id my.foo &
gnome-terminal --app-id my.foo

When executing the script

$ ./startGnomeTerm.sh
# Error creating terminal: The name my.foo was not provided by any .service files

I have even attempted to share all shell variables with the script by executing

$ export > shell_vars

Then placing this at the beginning of the script.

#!/bin/bash
source shell_vars
....

-UPDATE-

The solution is to add a slight delay to between the commands. Setting up the server takes longer than the script was allowing for, so the terminal tried to connect before the server was actually running.

Working script:

#!/bin/bash
/usr/libexec/gnome-terminal-server --app-id my.foo &
sleep 0.5
gnome-terminal --app-id my.foo
  • 1
    I don't share any aspect of your environment (no access to windows, not using Gnome anything), but it might be a timing issue in the script? What happens if you say introduce a sleep 2 after starting the terminal server? – tink Feb 20 at 20:02
  • Really don't understand a down-vote on this question. Seems a very good question. – Philip Couling Feb 20 at 20:08
  • @tink Lol! That was it! For all the things I tried and read, it never occurred to me that the commands were simply being executed too quickly in the script. If you provide that as an answer, I will accept it as the correct answer. – Chris Keeser Feb 20 at 23:11
  • @ChrisKeeser - ping :} – tink Feb 22 at 16:30
0

As discussed above: timing issue; introduce a sleep between the start of the terminal server and opening the new terminal. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.