不要命令,从当前目录中的shell脚本运行? [英] Do commands run from current directory in a shell script?
本文介绍了不要命令,从当前目录中的shell脚本运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在一个bash shell脚本我试过这两个版本:
In a bash shell script I tried these two versions:
java -jar abc.jar&
和
CMD="java -jar abc.jar&"
$CMD
第一verison工作,以及所述第二版本抱怨abc.jar无法找到。为什么呢?
The first verison works, and the second version complains that abc.jar cannot be found. Why?
推荐答案
命令执行从一个shell脚本当前目录运行。
Commands do run from current directory in a shell script.
这就是为什么在你的测试脚本的第一个命令的工作。
This is why the first command in your test script worked.
第二个命令可能无法正常工作,因为无论的Java
是不是在你的 $ {PATH}
或 abc.jar
是不是在你的 $ {CLASSPATH}
。你可以回声
这些环境变量或设置+ X
来调试你的庆典
脚本。
The second command may not work because either java
isn't in your ${PATH}
or abc.jar
isn't in your ${CLASSPATH}
. You could echo
these environment variables or set +x
to debug your bash
script.
这篇关于不要命令,从当前目录中的shell脚本运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文