0

我正在尝试使用数组在 3 个远程服务器中执行以下命令集,使用 Here Document,但出现错误

代码 -

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 运行它们不是我正在寻找的解决方案。

4

1 回答 1

2

查看整个此处的文档并搜索-e.

编辑:

用单引号将 END_TEXT 括起来,如下所示:

ssh ... <<-'END_TEXT'
...
END_TEXT

这将防止在远程服务器上可用之前用空字符串替换 $VALUE。

于 2012-10-31T16:15:12.857 回答