我在下面有一个简单的 shell 脚本:
#!/bin/bash
# Hadoop Clear
readOnly hadoop = /opt/hadoop/bin/hadoop
hadoop fs -rm -r /
当我在同一台机器的终端上运行脚本时,一切正常,没有错误。
现在,我想远程调用这个脚本。所以从我的 java
程序,我做一个 ssh
到服务器,并将脚本调用为:
sh <full Path to script>
.
我收到一条错误消息:
clearHadoop.sh: readOnly: not found
clearHadoop.sh: hadoop not found
知道为什么会这样吗?
最佳答案
readonly
是一个 bash 关键字,而不是 readOnly
。
这听起来像是您在 shell init 文件中将 hadoop
的路径添加到 $PATH
中,该文件仅影响交互式 session (因此不影响远程 session )。
另外 sh
不是 /bin/bash
。如果你想要 bash
使用 bash
而不是 sh
。
关于java - 远程执行shell脚本时找不到"readOnly"等符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28810911/