我正在尝试使用数组中的3个远程服务器中执行以下命令集,但使用此处的文档,但是获取错误
代码 -
ssh -oPasswordAuthentication=no $remoteUser@${SERVER[i]} <<-END_TEXT
VALUE=`cat /home/cognos/cognos/c8/configuration/cogstartup.xml | grep -i xsd:long | head -1 | cut -d">" -f2 | sed 's/[:/<|crn:value]*//g'`
VALUE_BACKUP=$VALUE
........................ (many more lines of code)
RESULT1=`perl -e '@stats = stat("/home/cognos/cognos/c8/configuration/signkeypair"); print ((time - $stats[9]) < '$VALUE');'`
END_TEXT
和错误:
**error -**
syntax error at -e line 1, near "< )"
Execution of -e aborted due to compilation errors.
syntax error at -e line 1, near "< )"
Execution of -e aborted due to compilation errors.
syntax error at -e line 1, near "< )"
Execution of -e aborted due to compilation errors.
ps-使用SCP将命令复制到远程服务器,然后使用SSH运行它们不是我正在寻找的解决方案。
查看此处的整个文档,并搜索-e
。
编辑:
将end_text包含在单引号中,如这样:
ssh ... <<-'END_TEXT'
...
END_TEXT
这将在远程服务器上可用之前,以防止用空字符串替换$ value。