Open a terminal via gnome-terminal then execute command, error : "failed to execute child process"" [closed]
Asked Answered
M

1

10

Via a bash command, I want open a terminal and, from the new terminal, execute a simple bash command.

I tried:

gnome-terminal -- "/bin/bash -c ls"

But I got this error:

enter image description here

I don't understand the error and I cannot find an example anywhere for help.

Misfeasance answered 5/2, 2018 at 17:16 Comment(11)
Use the -e option. It's taking that command as the name of a program to run, not a shell command to execute.Patroclus
SO is for programming questions, not questions about using or configuring Linux and its applications. SuperUser.com or unix.stackexchange.com would be better places for questions like this.Patroclus
-e arg is deprecied :/ ('Option “-e” is deprecated and might be removed in a later version of gnome-terminal.'). Nothing work when I use -e option, I get just the "deprecated" messageMisfeasance
gnome-terminal -- /bin/bash -c ls. No quotes.Susceptive
nothing happen when I don't use quotes, no error, no new terminal, nothingMisfeasance
Probably because it's exiting immediately. Try instead, say, gnome-terminal -- /bin/bash -c 'ls; sleep 3'Susceptive
BTW, this has already been asked and answered here before. Give me a minute to find the duplicate to close the question...Susceptive
hannn your right ! its work ! is there a way for 'keep' alive the new terminal after the command ?Misfeasance
Give it any command that waits indefinitely without exit.Susceptive
ok =) thank you a lot !Misfeasance
Ahh -- the other question I was thinking about was #48237037, but while the answer covers some similar ground, it's not quite a duplicate.Susceptive
S
16

The quotes are telling the terminal to run an executable in /bin called bash -c ls (with the spaces as part of its name!). There exists no such executable.

Take them out:

gnome-terminal -- /bin/bash -c ls

...or, to actually make something stay open until the user provides input...

gnome-terminal -- /bin/bash -c 'ls; read'
Susceptive answered 5/2, 2018 at 17:22 Comment(3)
thank you :) as I ask from comment , is there a way for keep alive the new terminal regardless the command executed ?Misfeasance
On a GNU system, you could run sleep infinity as the final command. More portably, though, I'd expect that sleep $(( 60 * 60 * 24 * 365 )) (to sleep for a year) would probably be good enough.Susceptive
You can try gnome-terminal -- /bin/bash -c 'ls;exec /bin/bash'Laos

© 2022 - 2024 — McMap. All rights reserved.