0

I am creating a bash file which will download file daily but file name is dynamic it generates file on the basis of date something like '20190819.log' My code is as follows :

   export SSHPASS=$SFTP_PASS
   DATE=`$DATE -d "-1 day" +"%Y%m%d"`

   sshpass -e sftp -oBatchMode=no -b - $SFTP_USER@$SFTP_HOST<<-'EOF'
    mget $DATE.log
   EOF

But in line mget $DATE.log it is treating $DATE as string. Need help...Thanks in advance.

BASEER HAIDER JAFRI
  • 939
  • 1
  • 17
  • 35

1 Answers1

1

When you put quotes around the here-doc end delimiter (<<-'EOF' in this case), you are asking the shell to not expand parameters in the here-doc. If you want shell variables to be expanded, lose the quotes (<<-EOF).

But in this particular case, you might find that scp is easier to use.

rici
  • 234,347
  • 28
  • 237
  • 341