Unable to start new gnome terminals from shell script when remotely logging in through ssh

Clash Royale CLAN TAG#URR8PPP
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
bash shell ssh fedora gnome-terminal
add a comment |
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
bash shell ssh fedora gnome-terminal
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 asleep 2after 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
add a comment |
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
bash shell ssh fedora gnome-terminal
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
bash shell ssh fedora gnome-terminal
bash shell ssh fedora gnome-terminal
edited Feb 20 at 23:14
Chris Keeser
asked Feb 20 at 19:44
Chris KeeserChris Keeser
133
133
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 asleep 2after 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
add a comment |
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 asleep 2after 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
1
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
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
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
@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
@ChrisKeeser - ping :}
– tink
Feb 22 at 16:30
add a comment |
1 Answer
1
active
oldest
votes
As discussed above: timing issue; introduce a sleep between the start of the terminal server and opening the new terminal. :)
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f501941%2funable-to-start-new-gnome-terminals-from-shell-script-when-remotely-logging-in-t%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As discussed above: timing issue; introduce a sleep between the start of the terminal server and opening the new terminal. :)
add a comment |
As discussed above: timing issue; introduce a sleep between the start of the terminal server and opening the new terminal. :)
add a comment |
As discussed above: timing issue; introduce a sleep between the start of the terminal server and opening the new terminal. :)
As discussed above: timing issue; introduce a sleep between the start of the terminal server and opening the new terminal. :)
answered Feb 20 at 23:49
tinktink
4,49711222
4,49711222
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f501941%2funable-to-start-new-gnome-terminals-from-shell-script-when-remotely-logging-in-t%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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 2after 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