I'm trying to automate an existing FTP process that I have running on one of my machines, I have a script that works ok (thanks to this board
) but I need to be able to use the script to send some different files that don't always have the same name. I have created a file that will contain the name of the file that needs to be transferred but I'm having trouble getting the script read this file and use is as a variable for the FTP.
If tried adding a few while read type statements but all I manage to do is either break the script all together or echo the file name to command line.
Please help
here is the script:
#!/bin/ksh
file=$1
remote=$2
HOME=/MYFILESYSTEM
FTP_HOST=XX.XX.XX.XX
FTP_LOGIN=XXXXX
FTP_PASSWORD=XXXXX
mylog=ftp_session.log
#Write FTP attempt to log
echo "$(date "+%H:%M:%S") - Attempt to FTP $1 to $2" > $mylog
# do the FTP put
cd $HOME
ftp -i -n <<EOF >> $mylog
open $FTP_HOST
user $FTP_LOGIN $FTP_PASSWORD
put $file $remote
quit
EOF
I've tried using statements like cat ftp.list | while read FILE but can't seem to the output to replace the $FILE or $REMOTE variables correctly.
Please help and thanks in advance...........