2010.01.19 10:27

[Script]Shell프로그램을 이용한 FTP전송


Local서버에서 Remote서버로 다량의 디렉토리와 하위 파일들을 ftp를 이용해서 전송시 쉘프로그램

 

------------------------------------------------------------------------------------------

ftpFaxPut.sh

------------------------------------------------------------------------------------------

#!/bin/sh
FTP_CMD="/usr/bin/ftp";
FTP_HOST="000.000.000.000";
FTP_USER="user";
FTP_PASS="passwd";
LOCAL_PATH="/data/tmax/tsdms_New/fileupload/fax/prepared";
BACKUP_PATH="/data/tmax/tsdms_New/fileupload/fax/completed";

export FTP_CMD FTP_HOST FTP_USER FTP_PASS LOCAL_PATH

DIRECTORYS=`ls -1 $LOCAL_PATH`

date >> /data/tmax/cronsh/ftp/ftpFaxexcutedate.txt

for temp in $DIRECTORYS
  do
    if [ ! -f $LOCAL_PATH/$temp ]
    then
      echo "GET DIRECTORY : $temp";
      echo "GET DIRECTORY : $temp" >> /data/tmax/cronsh/ftp/ftpFaxexcutedate.txt
      /data/tmax/cronsh/ftp/ftpFaxPutFile.sh $FTP_CMD $FTP_HOST $FTP_USER $FTP_PASS $LOCAL_PATH $temp > /dev/null
    fi
  done

# File Move after File Transfer
mv $LOCAL_PATH/* $BACKUP_PATH/


exit 0

 

------------------------------------------------------------------------------------------

ftpFaxPutFile.sh

------------------------------------------------------------------------------------------

#!/bin/sh

$1 -n $2 << EOF
user $3 $4
bi
prompt
mkdir $6
lcd $5/$6
cd $6
mput *
bye
<< EOF

exit 0


참고 : http://blog.naver.com/wpaddle/100094321257

Trackback 0 Comment 0