I have a file that will have the same name every day, but it will be
updated hourly on the ftp server, thus only the timestamp will be
different. It must be retrieved 24 times a day.
I have written a ksh script that will check the timestamp and proceed
accordingly depending on the timestamp found. However the way it is
currently written I log into the ftp server twice. First time in, I
dir . logname and then grep this for the timestamp. If it matches the
last timestamp used(stored in Oracle), I halt the script but if it
does not match then I open another ftp session to actually get the
file.
My question is can someone point me in the right direction to learn
how to do this with a single connection before I have to put it on the
production box?
How can something like the following be modified to work correctly?
If the !TESTVAR line spawns a new session, how can I issue a set of OS
commands in it's place and check the return code before issuing the
get command?
#!/bin/ksh
print "### inside ftp script ###"
print "### ftp host is " $1 " ###"
print "### user is " $2 " ###"
print "### filename is " $4 " ###"
print
ftp -n -v $1 <<EOF
binary
user $2 $3
dir . dir.log
!TESTVAR=`grep $4 dir.log | awk '{print $6 " " $7 " " $8 }'`
get $4 $DEST_DIR/$4
EOF