tdu*_*ubz 1 command-line bash scripts gnome-terminal
我已经为我的脚本尝试过这个:
\n\n#!/bin/sh\ngnome-terminal -- cd Server\ngnome-terminal -- ./start.sh\nRun 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,完全是新手。
\ncd是一个 shell 内置命令 - 您不能直接在终端中执行它,它需要一个 shell。
例如
gnome-terminal -- sh -c 'cd Server && ./start.sh'
Run Code Online (Sandbox Code Playgroud)
(您可能需要给出绝对值,/path/to/Server具体取决于运行命令的位置)。