如何创建脚本来打开新终端并执行命令?

tdu*_*ubz 1 command-line bash scripts gnome-terminal

我已经为我的脚本尝试过这个:

\n\n
#!/bin/sh\ngnome-terminal -- cd Server\ngnome-terminal -- ./start.sh\n
Run Code Online (Sandbox Code Playgroud)\n\n

但是,当我运行它时,我收到此错误:

\n\n

当我只想要一个带有两个命令的终端时,它还会打开两个终端。

\n\n

为此终端创建子进程时出错

\n\n

无法执行子进程\xe2\x80\x9ccd\xe2\x80\x9d(没有这样的文件或目录)

\n\n

如何让命令正确运行?

\n\n

我使用的是 Ubuntu 19.04,完全是新手。

\n

ste*_*ver 5

cd是一个 shell 内置命令 - 您不能直接在终端中执行它,它需要一个 shell。

例如

gnome-terminal -- sh -c 'cd Server && ./start.sh'
Run Code Online (Sandbox Code Playgroud)

(您可能需要给出绝对值,/path/to/Server具体取决于运行命令的位置)。