exec抛出“没有这样的文件或目录”。但是文件夹存在,文件也存在

发布于 2025-02-05 03:43:49 字数 413 浏览 3 评论 0原文

我正在使用以下exec命令:

mainfolder 是主要文件夹 内部 mainscript.sh 设置文件夹

mainscript.sh (位于 mainfolder 中):

....
...
...
exec "../settings/helper.sh"

文件helper.sh是当前目录之前的一个文件夹,在设置文件夹中 但是exec投掷否此类文件或目录

知道如何解决这个问题?

I'm using the following exec command:

MainFolder is the main folder
inside it mainScript.sh and settings folder

mainScript.sh (Located in MainFolder) :

....
...
...
exec "../settings/helper.sh"

The file helper.sh is located one folder before the current directory , in settings folder
but exec throws no such file or directory.

Any idea how to fix this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等你爱我 2025-02-12 03:43:49

您必须在脚本mainscript.sh中声明

MAINFOLDER=$(dirname $(readlink -f $0))

可变

mainfolter

exec "${MAINFOLDER}/settings/helper.sh"

exec "${MAINFOLDER}/../settings/helper.sh"

You have to declare the variable MAINFOLDER in your script mainScript.sh

MAINFOLDER=$(dirname $(readlink -f $0))

and call any script relative to $MAINFOLDER

if settings is in $MAINFOLDER

exec "${MAINFOLDER}/settings/helper.sh"

if settings is located one folder before

exec "${MAINFOLDER}/../settings/helper.sh"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文