简体   繁体   中英

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 . 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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM