ftp issue

Hi again,

I'm using the following shell script via cron to upload the daily log files from my shell to the web server so we can view them online. But somehow logs get corrupted and i don't know what's issue. I would really appreciate for your help please.

Shell Script: ftp.sh

#!/bin/sh
HOST='test.com'
USER='test'
PASSWORD='test1234'
LOGS=$HOME/tst/stats
DATE=$(date +%y%m%d)
cd $LOGS
filename=$(ls -t tst.log*|sed q)
tar zcvf daily.$DATE-log.tar.gz $filename
ftp -n $HOST > /home/user/ftp-hist/ftp.worked 2> /home/user/ftp-hist/ftp.failed <<END_SCRIPT
quote USER $USER
quote PASS $PASSWORD
cd /home/user/public_html/logs
prompt off
put daily.$DATE-log.tar.gz
quit
END_SCRIPT
exit 0

Thanks and best regards
user

Ftp uses ASCII-transfer mode by default. A zipped tar is binary.
Issue the command 'binary' to tell ftp to treat your upload as such.

2 Likes

perfect, worked after adding binary, thanks so much edehont

Yeah, I had the same problem just days ago...