文件壓縮傳送
#!/user/bin/ksh
. ~/.profile
#############################################################
# zip file to remote host
#############################################################
LOCAL_DIR1="/sducy/crmDateSync/"
LOCAL_DIR2="/sducy/crmDateSync/"
LOCAL_DIR3="/sducy/crmDateSync/"
LOCAL_DIR4="/sducy/crmDateSync/"
FTP_DIR1="/sducy/crmDateSync/ftp_file/"
FTP_DIR2="/sducy/crmDateSync/ftp_file/"
FTP_DIR3="/sducy/crmDateSync/ftp_file/"
FTP_DIR4="/sducy/crmDateSync/ftp_file/"
BACK_DIR="/sducy/backpro/syncDate/"
#######################################
#frist dir
cd $LOCAL_DIR1
for i in `ls -l | grep ^d | awk ‘{print $9}‘`
do
echo $i
md5_filename=‘message.properties‘
echo "difine md5_file:$md5_filename"
cd $i
##liru:MftXfeRemuClainDocSrc.json
tmp_filename=`ls MftXfeRemuClainDocSrc*`
s_filename=`ls $tmp_filename | awk -F ‘.‘ ‘{printf$1}‘`
echo ‘define s_filename:$s_filename‘
zip $s_filename.zip $tmp_filename $md5_filename
mv $s_filename.zip $FTP_DIR1
cd ..
echo "$LOCAL_DIR1$i"
rm -rf "$LOCAL_DIR1$i"
done
#frist dir
cd $LOCAL_DIR2
for i in `ls -l | grep ^d | awk ‘{print $9}‘`
do
echo $i
md5_filename=‘message.properties‘
echo "difine md5_file:$md5_filename"
cd $i
##liru:MftXfeRemuClainDocSrc.json
tmp_filename=`ls MftXfeRemuClainDocSrc*`
s_filename=`ls $tmp_filename | awk -F ‘.‘ ‘{printf$1}‘`
echo ‘define s_filename:$s_filename‘
zip $s_filename.zip $tmp_filename $md5_filename
mv $s_filename.zip $FTP_DIR2
cd ..
echo "$LOCAL_DIR2$i"
rm -rf "$LOCAL_DIR2$i"
done
#frist dir
cd $LOCAL_DIR3
for i in `ls -l | grep ^d | awk ‘{print $9}‘`
do
echo $i
md5_filename=‘message.properties‘
echo "difine md5_file:$md5_filename"
cd $i
##liru:MftXfeRemuClainDocSrc.json
tmp_filename=`ls MftXfeRemuClainDocSrc*`
s_filename=`ls $tmp_filename | awk -F ‘.‘ ‘{printf$1}‘`
echo ‘define s_filename:$s_filename‘
zip $s_filename.zip $tmp_filename $md5_filename
mv $s_filename.zip $FTP_DIR1
cd ..
echo "$LOCAL_DIR3$i"
rm -rf "$LOCAL_DIR3$i"
done
#frist dir
cd $LOCAL_DIR4
for i in `ls -l | grep ^d | awk ‘{print $9}‘`
do
echo $i
md5_filename=‘message.properties‘
echo "difine md5_file:$md5_filename"
cd $i
##liru:MftXfeRemuClainDocSrc.json
tmp_filename=`ls MftXfeRemuClainDocSrc*`
s_filename=`ls $tmp_filename | awk -F ‘.‘ ‘{printf$1}‘`
echo ‘define s_filename:$s_filename‘
zip $s_filename.zip $tmp_filename $md5_filename
mv $s_filename.zip $FTP_DIR4
cd ..
echo "$LOCAL_DIR1$i"
rm -rf "$LOCAL_DIR4$i"
done
#########################FTP LOCIC BEGIN ###############################
#remote host
REMOET_IP="10..."
REMOTE_NAME="jscrmapp"
REMOTE_PASS="iuiouou"
#remote dir
REMOTE_DIR1="/jsmft/JS_REM/MFTS/"
REMOTE_DIR2="/jsmft/JS_REM/MFTS/"
REMOTE_DIR3="/jsmft/JS_REM/MFTS/"
REMOTE_DIR4="/jsmft/JS_REM/MFTS/"
echo "begion to ftp"
##ftp file
ftp -nv $REMOTE_IP <<!
user $REMOTE_NAME $REMOTE_PASS
bin
pass promtp off
lcd $FTP_DIR1
cd $REMOTE_DIR1
mput *
!mv * $BACK_DIR
lcd $FTP_DIR2
cd $REMOTE_DIR2
mput *
!mv * $BACK_DIR2
lcd $FTP_DIR3
cd $REMOTE_DIR3
mput *
!mv * $BACK_DIR
bye
!
echo "Complete!!"
exit 0
#############################FTP LOGIC END##################################
####OTHER
year=`date +%Y`
month=`date +%m`
tmonth=`expr $month + 12 -2`
tmonth=`expr $month % 12 `
tyear=$year
echo $tmonth
if [ $tmonth -gt 10 ]; then
tyear=`expr $year -1`
fi
echo $tyear
###
for i in `ls req_e2c_reapack* | awk -F ‘.‘ ‘{print $1}‘`
do
echo $i
region=`echo ${i##*_}`
echo region
mv $i.txt ${i}_000001.txt
mv ${i}_000001.txt ${DIR_REQ}${region}
done
##########Clean file out of date begin
CleanFile="rsp_e2c_reapackets_"
suffix="*.txt"
month=`date +%m`
year=`date +%Y`
tmonth=0
if [ $month -gt 6 ]; then
month=`expr $month - 6 `
else
month=`expr $month +12 - 6 `
year=`expr $year - 1 `
fi
echo $month |awk ‘{printf"%02d ", $0}‘ | read tmonth
RECleanFile=`expr $CleanFile$year$tmonth`
cd $DIR_RESP_BAK
rm $RECleanFile$suffix
echo "clean file out of date end"
exit 0
文件壓縮傳送