Linux 从 bash shell 启动一个新的 bash shell
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6218706/
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
Starting a new bash shell from a bash shell
提问by providence
I would like to run a program from the bash shell. When the program runs, it dominates the entire shell, so I would like to start a new shell and run the program from there. Currently I am doing:
我想从 bash shell 运行一个程序。当程序运行时,它支配了整个shell,所以我想启动一个新的shell并从那里运行程序。目前我正在做:
gnome-terminal -x "cd Dropbox; program_name"
However that give me the error Failed to execute the child process, no such file or directory. I believe thats because the new terminal has no time to initialize. How can I fix this?
但是,这给了我错误无法执行子进程,没有这样的文件或目录。我相信那是因为新终端没有时间初始化。我怎样才能解决这个问题?
采纳答案by tjm
I admit this doesn't really answer your question, but I think it solves your problem.
我承认这并不能真正回答您的问题,但我认为它可以解决您的问题。
Why not just use &
to send it to the background. You can see if it's still running with jobs
and bring it back to the foreground with fg
, you can also send it back to the background, by first stopping it with Ctrl+Zthen bg
为什么不只是&
用来将它发送到后台。您可以查看它是否仍在运行jobs
并使用 将其带回前台fg
,您也可以将其发送回后台,首先使用Ctrl+Z然后停止它bg
Example to try.
尝试的例子。
> sleep 20 &
> jobs
> fg [jobNumber]
[Ctrl-Z]
> jobs
> bg [jobNumber]
> jobs
回答by Kim Stebel
use the absolute path to the program or cd before calling gnome-terminal. And you need a & to put it in the background.
在调用 gnome-terminal 之前使用程序或 cd 的绝对路径。你需要一个 & 把它放在后台。
cd Dropbox; gnome-terminal -x "program_name" &
回答by patapizza
Try adding "&" at the end of your command, e.g.:
尝试在命令末尾添加“&”,例如:
gnome-terminal &
I don't know if it's working with gnome-terminal, but it worked well with mrxvt.
我不知道它是否适用于 gnome-terminal,但它适用于 mrxvt。
回答by grundprinzip
回答by grundprinzip
/bin/bash -c "/path/to/prog"
But look into the sleep
command also.
但sleep
也要查看命令。
回答by lukasz
Try:
尝试:
bash -c 'gnome-terminal -x cd /absolute-path && program_name'