此时情绪此时天,无事小神仙
好好生活,平平淡淡每一天

编辑

Linux环境FTP远程复制

FTP API
http://people.apache.org/~rwinston/commons-net-2.0/site/apidocs/org/apache/commons/net/ftp/FTP.html

FTP登录校验命令:

# 登录:ftp 192.168.111.1
# 根据提示输入用户 密码
# 退出:bye

远程复制:把FTP服务器上的文件复制到Linux服务器上脚本

ftp -n<<!
open 192.168.111.1
user username password
binary
prompt
get /ftp_path/ftp_file1.txt /linux_path/linux_file1.txt
get /ftp_path/ftp_file2.txt /linux_path/linux_file2.txt
get /ftp_path/ftp_file3.txt /linux_path/linux_file3.txt
close
bye
!
echo `date +"%Y-%m-%d %H:%M:%S"` FTP replicated succeed!>>/linux_log_path/ftp_replicate_log.log

动态传参命令:sh ftp_replicate.sh 192.168.111.1 username password

FTP_IP="$1"
FTP_USER="$2"
FTP_PASSWORD="$3"
ftp -n<<!
open $FTP_IP
user $FTP_USER $FTP_PASSWORD
binary
prompt
get /ftp_path/ftp_file1.txt /linux_path/linux_file1.txt
get /ftp_path/ftp_file2.txt /linux_path/linux_file2.txt
get /ftp_path/ftp_file3.txt /linux_path/linux_file3.txt
close
bye
!
echo `date +"%Y-%m-%d %H:%M:%S"` FTP replicated succeed!>>/linux_log_path/ftp_replicate_log.log
posted @ 2021-04-15 13:48  踏步  阅读(190)  评论(0编辑  收藏  举报