[英]Getting an error EOF : Command no found when using ssh
I am trying to rename the filenames in remote server like filename-dirname.suffix and copy the files to my server . 我正在尝试重命名远程服务器中的文件名,如filename-dirname.suffix并将文件复制到我的服务器。 I had written code like ....
我写过类似...的代码。
#!/usr/bin/bash
TRANSFERSERVERXMLS="/emp/transfer/XMLS"
REMOTESERVERXMLS="remoteemp/empdir/XMLS"
# renaming the filenames in remote server like filename-dirname.suffix
ssh abc@xyz REMOTESERVERXMLS=$REMOTESERVERXMLS 'bash -s'<< 'EOF'
for i in $REMOTESERVERXMLS/* ; do
if [[ -d $i ]]; then
dirname=$(basename $i)
for j in $REMOTESERVERXMLS/$dirname/* ; do
fname="$(basename "$j")"
prefix=$(echo $fname | awk -F "." 'NF{NF-=1};1')
suffix=$(echo $fname | awk -F "." '{print $NF}')
target=$prefix-$dirname.$suffix
mv $REMOTESERVERXMLS/$dirname/"$fname" $REMOTESERVERXMLS/$dirname/"${target// /_}"
done
fi
done
EOF
scp abc@xyz:${REMOTESERVERXMLS}/*/* ${TRANSFERSERVERXMLS}
Getting an error : EOF:Command not found and scp is not working ( not able to copy into calling server) 收到错误消息:EOF:找不到命令,并且scp无法正常工作(无法复制到调用服务器中)
You have a space before the delimiter EOF
. 分隔符
EOF
之前有一个空格。 Do not indent EOF
at the end of your "here document". 不要在“此处文档”末尾缩进
EOF
。 The delimiter ( EOF
) must be the only thing on the line, with no leading or trailing whitespace. 分隔符(
EOF
)必须是行中唯一的东西,没有前导或尾随空格。
Alternatively use <<- 'EOF'
and indent with a tab. 或者使用
<<- 'EOF'
并在选项卡上缩进。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.