bash 通过 gnome-terminal 打开终端,然后执行命令,错误:“无法执行子进程””

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48627989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 16:49:06  来源:igfitidea点击:

Open a terminal via gnome-terminal then execute command, error : "failed to execute child process""

bashgnome-terminal

提问by matthieu lopez

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

通过 bash 命令,我想打开一个终端,然后从新终端执行一个简单的 bash 命令。

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.

我不明白这个错误,我无法在任何地方找到帮助的例子。

回答by Charles Duffy

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

引号告诉终端在/bin调用中运行可执行文件bash -c ls(空格作为其名称的一部分!)。不存在这样的可执行文件。

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'