shell_ftp对传输的文件进行压缩

#!/bin/bash

FilTranDay=$1

cd /gaps/cib

IP=`awk -F '=' '/\[FTP\]/{a=1}a==1&&$1~/IP/{print $2;exit}' cibftp.ini `

USR=`awk -F '=' '/\[FTP\]/{a=2}a==2&&$1~/USR/{print $2;exit}' cibftp.ini `

PASSWD=`awk -F '=' '/\[FTP\]/{a=3}a==3&&$1~/PASSWD/{print $2;exit}' cibftp.ini `

FTPHOME=`awk -F '=' '/\[FTP\]/{a=4}a==4&&$1~/FTPHOME/{print $2;exit}' cibftp.ini `

 

echo "----传输文件进行压缩处理"

 

 

#DD=`echo $FilTranDay|cut -c 7-8 `

LOCALPATH=/gaps/cib/history/iut/${FilTranDay}

echo "----本地文件存放路径="$LOCALPATH

 

if ! [ -d $LOCALPATH ]

then

    echo "----ERROR: "${LOCALPATH}"路径不存在"

    echo "系统退出"

FilTranDay=$1

cd /gaps/cib

IP=`awk -F '=' '/\[FTP\]/{a=1}a==1&&$1~/IP/{print $2;exit}' cibftp.ini `

USR=`awk -F '=' '/\[FTP\]/{a=2}a==2&&$1~/USR/{print $2;exit}' cibftp.ini `

PASSWD=`awk -F '=' '/\[FTP\]/{a=3}a==3&&$1~/PASSWD/{print $2;exit}' cibftp.ini `

FTPHOME=`awk -F '=' '/\[FTP\]/{a=4}a==4&&$1~/FTPHOME/{print $2;exit}' cibftp.ini `

 

echo "----传输文件进行压缩处理"

 

 

#DD=`echo $FilTranDay|cut -c 7-8 `

LOCALPATH=/gaps/cib/history/iut/${FilTranDay}

echo "----本地文件存放路径="$LOCALPATH

 

if ! [ -d $LOCALPATH ]

then

    echo "----ERROR: "${LOCALPATH}"路径不存在"

    echo "系统退出"

    exit 1

fi

cd $LOCALPATH

LIST=`ls $LOCALPATH|grep -v ".gz"|grep -v ".flg"`

for LN in $LIST

do

     rm -f ${LOCALPATH}"/"${LN}".gz"

     gzip -f ${LOCALPATH}"/"$LN >${LN}".gz"

done

echo "----FTP文件传输开始: `date +\"%Y-%m-%d %H:%M:%S\"`"

 

 

ftp -i -n $IP <<-FTPINI

user $USR $PASSWD

bin

cd $FTPHOME/$FilTranDay

pwd

prompt

binary

mput *.dat.gz

close

bye

FTPINI

 

if [ $? -ne 0 ]

then

     echo ""

     echo "----ERROR: ftp数据文件传输失败"

   echo "系统退出"

   exit 1

fi

echo ""

echo "----INFO: ftp数据文件传输成功"

 

ftp -i -n $IP <<-FTPINI

user $USR $PASSWD

bin

cd $FTPHOME/$FilTranDay

pwd

prompt

binary

mput *.flg

close

bye

FTPINI

 

if [ $? -ne 0 ]

then

     echo ""

     echo "----ERROR: ftp标志文件传输失败 "

   echo "系统退出"

   exit 1

fi

echo ""

echo "----INFO: ftp标志文件传输成功"

echo "----FTP文件传输结束:  `date +\"%Y-%m-%d %H:%M:%S\"`"

你可能感兴趣的:(shell)