Hi All,
I have created a script for an sftp transfer that works without a date variable being passed, I want it to work with a date variable being passed.
So, my initial script, mainsftp.sh, looks like this:
-----------------------------------------------------------------------
# Variables
#
ODAY=$1
LDIR1='/sftp/incoming'
USER1=username
MACHINE1=nnn.nnn.nnn.nnn
# Main
sftp -b ~/folder/sftpcmd.txt $USER1@$MACHINE1 <<EOF
-----------------------------------------------------------------------
File sftpcmd.txt looks like this:
----------------------------------------------------------------------
lcd /ftp/dir
get filename_.csv
get filename_.txt
bye
----------------------------------------------------------------------
Now - the above code works for me and will retrieve all files filename_.csv and filename_.txt however, for the purposes of my job, I want to change sftpcmd to look as follows, with $ODAY being passed as $1 to the main script:
----------------------------------------------------------------------
lcd /ftp/dir
get filename_$ODAY.csv
get filename_$ODAY.txt
bye
----------------------------------------------------------------------
My question is two-fold:
a) Is there a way to have the ftp commands in the batchfile above within mainsftp.sh? or if not
b) Is there a way to pass the $ODAY variable from mainsftp.sh to sftpcmd.txt
I'm working on an AIX server.
Thanks,
Julie