shell 脚本 - 打开 xterm window 执行命令并继续执行脚本
shell script - open xterm window execute command and keep on executing script
我正在编写一个 shell 脚本,我需要我的脚本来打开一个 xterm window 运行 一个命令并且不关闭 xterm 继续执行该脚本。
该代码基本上是一个巨大的菜单案例。
这是我的脚本示例
...
example() {
echo -n "thingy > "
read thingy
echo -n "thingy1> "
read thingyl
xterm -hold -e *el command*
menux
}
...
问题:
脚本打开 xterm 执行命令并保持 window 打开但不会继续脚本,如果我按 ctrl + c 它会返回到 shell
这个变化
nohup xterm -hold -e *el command* &
会做你想做的。 nohup
告诉 shell 在父进程退出时不要向该子进程发送 HUP (1) 信号。 &
在后台使 xterm
命令 运行 以便脚本可以继续。 man nohup
有详细信息。
如果你想取消输出,那么以下将把所有输出转移到 /dev/null
而 2>&1
将确保 stderr
被定向到相同的地方。如果您想查看错误,请不要执行第二次重定向。
nohup xterm -hold -e *el command* > /dev/null 2>&1 &
man bash
有关于重定向的详细信息。
我正在编写一个 shell 脚本,我需要我的脚本来打开一个 xterm window 运行 一个命令并且不关闭 xterm 继续执行该脚本。
该代码基本上是一个巨大的菜单案例。
这是我的脚本示例
...
example() {
echo -n "thingy > "
read thingy
echo -n "thingy1> "
read thingyl
xterm -hold -e *el command*
menux
}
...
问题:
脚本打开 xterm 执行命令并保持 window 打开但不会继续脚本,如果我按 ctrl + c 它会返回到 shell
这个变化
nohup xterm -hold -e *el command* &
会做你想做的。 nohup
告诉 shell 在父进程退出时不要向该子进程发送 HUP (1) 信号。 &
在后台使 xterm
命令 运行 以便脚本可以继续。 man nohup
有详细信息。
如果你想取消输出,那么以下将把所有输出转移到 /dev/null
而 2>&1
将确保 stderr
被定向到相同的地方。如果您想查看错误,请不要执行第二次重定向。
nohup xterm -hold -e *el command* > /dev/null 2>&1 &
man bash
有关于重定向的详细信息。