서버 Server

shell 에서 ftp 접근

은둔한량 2013. 2. 18. 15:17
반응형
##################################### korn shell
#!/bin/ksh

SERVERNAME = 192.000.000.000
DIRNAME=/DATA1/TO_SERV
LOC_DIRNAME=/home/ftpdata/daily_data/FROM_SERV

ACCT=ftpuser
PASS=ftppwd
CURDATE=`date '+%Y%m%d'`
FILENAME=testfile.dat

ftpget(){
date

# Using ftp to get the sam file
echo $CURDATE
date
echo "Trying to connect to machine $SERVERNAME"
unset noclobber

ftp -n $SERVERNAME <<EOF 
user $ACCT $PASS  
hash  
prompt   
cd $DIRNAME  
lcd $LOC_DIRNAME 
bin  
get $1.$CURDATE  
bye
EOF

date
}




##################################### c shell

#!/bin/csh 

set SERVERHOST  = 192.000.000.000
set DIRNAME     = /DATA1/TO_SERV
set LOC_DIRNAME     = /home/ftpdata/daily_data/FROM_SERV

set ACCT        = ftpuser
set PASS        = ftppwd
set FILENAME    = testfile.dat

set CURDATE=`date '+%Y%m%d'`
# Using ftp to get the sam file
echo $CURDATE

date
echo "Trying to connect to machine $SERVERHOST"
unset noclobber
echo  "open $SERVERHOST \
user $ACCT $PASS \
hash \
prompt \
cd $DIRNAME \
lcd $LOC_DIRNAME \
bin \
get $FILENAME.$CURDATE \
quit" | ftp -n -i

sleep 1
#############################################################
ftp -n << !
#open 128.12.248.18
open 10.6.4.186
user ftpuser yfirst
binary
prompt
lcd /home/yfirst/daily_data/FROM_SERV
cd /DATA1/TO_SERV
get $1
bye
!
#############################################################

echo "+++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "+ get from iids                                    "
echo "+++++++++++++++++++++++++++++++++++++++++++++++++++"

if ( ! -f  "$LOC_DIRNAME/$FILENAME.$CURDATE" ) then
    echo "File($LOC_DIRNAME/$FILENAME.$CURDATE) get fail."
    exit;
endif

반응형

'서버 Server' 카테고리의 다른 글

리눅스에서 apm설치  (0) 2013.09.05
cron 설명  (0) 2013.02.25
Linux vi에서 한글파일이 깨져 보일 경우  (0) 2013.02.18
문자열, 파일, 디렉토리 찾기 (find와 grep활용)  (1) 2013.02.18
리눅스 파일 내용 찾기  (0) 2013.02.18