为什么该脚本不能在服务器上打开并行 gnome 终端?

为什么该脚本不能在服务器上打开并行 gnome 终端?

为什么我的服务器上不能有 parallel gnome-terminals,而我的客户端上可以。

下面是一个可以说明该问题的测试。

#!/bin/bash
# this is the parent script
gnome-terminal --command "./left.sh"
gnome-terminal --command "./right.sh"

#!/bin/bash
echo "this is the left script"
read -p "press any key to close this terminal" key

#!/bin/bash
echo "this is the right script"
read -p "press any key to close this terminal" key

当我在常规 ubuntu 桌面(maverick)上运行此程序时,我会看到两个终端。当我在服务器场的 maverick 服务器上运行此程序时,第二个窗口直到在我关闭第一个之后。我正在使用tightvncserver查看服务器桌面。

答案1

gnome-terminal本地运行使用拥有实际终端窗口的后台“工厂”服务器;命令gnome-terminal本身在通过 DBus 联系服务器并告诉它启动窗口后退出。远程运行时,它无法与工厂服务器通信,因此它会自行设置窗口,并且必须继续运行,直到该窗口关闭。

如果您将命令放在后台,&您将获得所需的效果,无论是远程还是本地(或使用--disable-factory哪个会导致本地命令的行为与远程命令相同)。wait在这种情况下,您可能需要脚本中的最终命令。

相关内容