FTP in Kshell

 

ftp -n  1.1.1.1 <<EOF
user $USER $PASSWD
lcd /opt/remote
binary
prompt
ls -l > list.txt
mget list.txt
quit
EOF
exit
# END OF SCRIPT

now put of conditions by reading list.txt on your location m/c. And download
if you find required files.

More options explaination are as below.
1. What is the "-n" paramter do for the ftp command

man ftp
     -n        Do not attempt "auto-login" upon  initial  connec-
               tion.  If  auto-login is not disabled, ftp  checks
               the .netrc file in the user's home  directory  for
               an  entry  describing  an  account  on  the remote
               machine.  If no entry exists, ftp  will prompt for
               the  login  name  of  the  account  on  the remote
               machine (the default is  the  login  name  on  the
               local  machine),  and, if necessary, prompts for a
               password and an account with which to login.

2. Why do you need "<<EOF" at the end of the ftp command.
      To tell the FTP program when to "exit"

3. What does the "binary" command do?
     set ftp transfer in "binary" mode

 

ftp -n -v 1.1.1.1 << EOF >> ${LOG}
user ${USER} ${PASS}
cd ..
get ${FILENAME} ${DOWNLFILE}
quit

EOF

if [ ! -s ${DOWNLFILE} ]; then
echo "`date` WARNING:file is not exists" >> ${LOG}
 
exit 2
fi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值