how to open a gnome terminal to execute a command with gnome-terminal, constantly?

左心房为你撑大大i 提交于 2019-12-18 02:50:52

问题


I have a sh file which includes those lines:

gnome-terminal\
  --tab\
    --title="ElasticSearch"\
    --working-directory="/home/username/program/bin"\
    -e "bash -c './somecommand'"\

when I run it, a gnome terminal will open and run a command for me. The problem is, when I press ctrl+c to stop the running command, the terminal closed. Is there a way to stop the running command and keep the terminal alive? Thanks in advance.


回答1:


Your command works fine but the gnome-terminal closes after the somecommand terminates, the reason being gnome-terminal not running the bash as it's default shell.

To get the bash prompt($) after the command command completes, you need to trigger it back.

-e "bash -c ./somecommand;bash"\



回答2:


-e has since been deprecated. Use gnome-terminal -- somecommand now.



来源:https://stackoverflow.com/questions/38135995/how-to-open-a-gnome-terminal-to-execute-a-command-with-gnome-terminal-constantl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!