Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP Question

Status
Not open for further replies.
May 23, 2002
8
0
0
US
My FTP is working, but I wanted to add some checks in the script to be safe:

1) Check for empty file, I extract data from an ingres DB, then FTP that data. What kind of check can I add to validate I don't have a file with no data ?

2) FTP LOG ? I'm sure this is easy, but is there a standard you guys would suggest for maybe creating a FTP log so that it could be reviewed in the event that the file failed to transfer ?

Here is my FTP logic at the moment:

### Build Header Line

RECTOT=`cat $OUTF | wc -l | awk '{printf("%06d\n",$1)}'`
RECTOT= $RECTOT + 1
StartTime=`date +%Y%m%d%H%M`


echo $HEADERID$PLANTCODE$FILETYPE$RECTOT$StartTime"
" >> $OUTFTP

for line in `cat $OUTF`
do
PARTNUM=`echo "$line" | awk -F: '{print $2}'`
QTY=`echo "$line" | awk -F: '{printf("%06d\n", $3)}'`
echo $DETAILID$PARTNUM" "$DEPT" "$GROUP" "$OP$StartTime$SHIFT$QTY" "$USER >> $OUTFTP
done

### FTP of File
# ftp -n $FTP_HOST<<END_SCRIPT
# quote USER $FTP_USER
# quote PASS $FTP_PASSWD
# ascii
# cd dir1/subdir
# quote site blkzise=93
# quote site lrecl=93
# put $LOCAL_DIR/$XMT_FILE $REMOTE_DIR/$XMT_FILE
# quit
# END_SCRIPT
# EOF #
 
To generate a log I think all you need is:

### FTP of File
# ftp -n $FTP_HOST<<END_SCRIPT>> /path/or/var/to/logfile.log

As for checking for empty file ??? ....
from man ftp:

size file-name
Return size of file-name on remote machine.

You may be able to do something with this ?

L
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top