Проба пера - скрипт на BASH'е


#!/bin/sh
##############################################
# (c), 2007, Shulepov #
##############################################

##### Setting configuration #############

localdir=/root/zov/localdir
utlfiledir=/u05/oradata/utlfile
ftphost=somehost.com
ftpuser=john
ftppass=doe
ftpdir=data
uploadfile=file_`date "+%d%m%Y"`.zip
xmlfile=file_`date "+%d%m%Y"`.xml
MAILTO=some@mail.ru

echo "Moving file into work directory"
mv $utlfiledir/$xmlfile $localdir

##### Packing file ###############
cd $localdir
zip -D $uploadfile $xmlfile

##### Upload to ftp-server ##############
echo "Uploading file using ftp..."
ftp -in $ftphost<<_EOF_
user $ftpuser $ftppass
cd $ftpdir
bin
put $uploadfile
ls -a out.txt
quit
_EOF_

rfsize=0
lfsize=`ls -al|grep $uploadfile|gawk '{print $5}'`
rfsize=`cat out.txt|grep $uploadfile|gawk '{print $5}'`

# Compare filesize of local and remote uploaded file #

if [ $lfsize -eq $rfsize ]
then # local file size equal remote file size

echo "File uploaded successfully!"
######## Cleaning local directory #######
for i in `ls $localdir`; do
rm $i
done

else # Error uploading
cat ../errmess.txt|mail -s 'Error' $MAILTO
fi

Самым интересным тут является то, что проверяется размер локального файла и выгруженного на ftp-сервер.