远程执行 shell 脚本时未找到 "readOnly" 和其他符号
"readOnly" and other symbols not found when executing shell script remotely
下面有一个简单的 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 初始化文件中将 hadoop
的路径添加到 $PATH
,该文件仅影响交互式会话(因此不影响远程会话)。
另外 sh
不是 /bin/bash
。如果你想要 bash
使用 bash
而不是 sh
.
您的 readOnly 行中有错字。至少我刚试过的 bash 都抱怨 readOnly
下面有一个简单的 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 初始化文件中将 hadoop
的路径添加到 $PATH
,该文件仅影响交互式会话(因此不影响远程会话)。
另外 sh
不是 /bin/bash
。如果你想要 bash
使用 bash
而不是 sh
.
您的 readOnly 行中有错字。至少我刚试过的 bash 都抱怨 readOnly