SFTP passing variables date

Hi,

Anyone can help me on how to solve my problem not getting the actual $DATE saying . Here my scripts;

#!/bin/sh
DATE='20110331'
sftp -oUserKnownHostsFile=/.ssh/known_hosts -oIdentityFile=/.ssh/id_rsa -b /source/transfer.sh server1@sftp.com  <<EOF

#tranfer.sh
put /getdir/tranx_$DATE.txt
quit
EOF

error saying : File "/getdir/tranx_$DATE.txt" not found

But the file was there : /getdir/tranx_20110331.txt

Thanks in Advance,
FSP

export DATE='20110331'

looks like transfer.sh contains the sftp command which are to be used by sftp in batch mode.
Variables in tranfer.sh will not be expanded as sftp would treat this as text file with the list of commands in it.

You can try to generate the command file from within your script and the try to use like... something like..

 
#!/bin/sh
DATE='20110331'
echo "put /getdir/tranx_$DATE.txt
quit
EOF" > tranfer.sh

sftp -oUserKnownHostsFile=/.ssh/known_hosts -oIdentityFile=/.ssh/id_rsa -b /source/transfer.sh server1@sftp.com  <<EOF