title: Getting an error EOF : Command no found when using ssh
body: <p>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 ....</p>
  
  <pre><code>  #!/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'&lt;&lt; '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}
  </code></pre>
  
  <p>Getting an error : EOF:Command not found 
  and scp is not working ( not able to copy into calling server)</p>