使用bash脚本中的 - 参数执行程序

时间:2021-02-19 01:47:18

I'm trying to run the following command in a bash script:

我正在尝试在bash脚本中运行以下命令:

antimicro --profile none.xml

In terminal it runs perfectly but not through bash, I've tried " and ' and [], just doesn't work..

在终端它运行完美但不通过bash,我尝试过“和'和[],只是不起作用..

Thank you.

1 个解决方案

#1


1  

The path to none.xml will be relative to $PWD when running the script, not relative to the script. You can either refer to the file with an absolute path, a relative path from $PWD, or a relative path from the script using "$(cd "$(dirname "${BASH_SOURCE\[0\]}")" && pwd)".

在运行脚本时,none.xml的路径将相对于$ PWD,而不是相对于脚本。您可以使用绝对路径引用该文件,使用$ PWD引用相对路径,或使用“$(cd”$(dirname“$ {BASH_SOURCE \ [0 \]}”)&& pwd从脚本引用相对路径)”。

#1


1  

The path to none.xml will be relative to $PWD when running the script, not relative to the script. You can either refer to the file with an absolute path, a relative path from $PWD, or a relative path from the script using "$(cd "$(dirname "${BASH_SOURCE\[0\]}")" && pwd)".

在运行脚本时,none.xml的路径将相对于$ PWD,而不是相对于脚本。您可以使用绝对路径引用该文件,使用$ PWD引用相对路径,或使用“$(cd”$(dirname“$ {BASH_SOURCE \ [0 \]}”)&& pwd从脚本引用相对路径)”。

相关文章