Getting an error EOF : Command no found when using ssh

依然范特西╮ 提交于 2019-12-01 10:23:30

问题


I am trying to rename the filenames in remote server like filename-dirname.suffix and copy the files to my server . 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)


回答1:


You have a space before the delimiter EOF. Do not indent EOF at the end of your "here document". The delimiter (EOF) must be the only thing on the line, with no leading or trailing whitespace.

Alternatively use <<- 'EOF' and indent with a tab.



来源:https://stackoverflow.com/questions/50990079/getting-an-error-eof-command-no-found-when-using-ssh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!