0

I have the below script to download today's file from the server

#!/bin/sh

IFS='
'
SYS_DT=$(date '+%d%h%Y')
SYS_FILE='BOMExtract_'$SYS_DT'.xlsx'
sshpass -p "123" sftp "admin@XXXX" << 'EOF'
cd /u01/admin/Oracle
lcd /u01/usr
get $SYS_FILE

But it is not taking the value of SYS_FILE in getting command. Can anyone please help to write bash inside sftp commands?

3
  • 1
    When you put quotes around EOF, variables aren't expanded inside the here-document. Commented Jan 19, 2022 at 5:32
  • 1
    Why did you do that if you wanted to use variables? Commented Jan 19, 2022 at 5:33
  • You are using sh not bash. Do not expect, that any Bash feature will work in your script. Commented Jan 19, 2022 at 8:33

1 Answer 1

0

I removed the quotes around EOF and that fixed the issue.Thanks Barmar

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.