windows
@echo off
REM 登陆ftp下载文件
set ftpUser=test_user
set ftpPass=123456
set ftpIP=192.168.1.205
set ftpFolder=/
set LocalFolder=C:/Users/Administrator/Desktop
set ftpFile=%temp%/TempFTP.txt
>"%ftpFile%" (
echo,%ftpUser%
echo,%ftpPass%
echo cd "%ftpFolder%"
echo lcd "%LocalFolder%"
echo bin
echo get test1.txt
echo get test2.txt
echo bye
)
ftp -v -i -s:"%ftpFile%" %ftpIP%
REM 移动下载的文件到指定证书目录
move test1.txt test_cert/test1.txt
move test2.txt test_cert/test2.txt
REM 接下来重新服务
:: net stop w3svc
:: net start w3svc
:: net stop nginx
:: net start nginx
linux
#!/bin/bash
# FTP服务器信息
ftp_server="192.168.1.205"
ftp_user="test_user"
ftp_password="123456"
# 远程文件路径
remote_file_path="/"
# 本地保存路径
local_folder="/root/"
# 要下载的文件列表
files=("test1.txt" "test2.txt")
# 下载文件
for file in "${files[@]}"; do
wget --ftp-user="$ftp_user" --ftp-password="$ftp_password" "ftp://$ftp_server$remote_file_path$file" -O "$local_folder$file"
# 检查下载是否成功
if [ $? -eq 0 ]; then
echo "文件 $file 下载成功"
else
echo "文件 $file 下载失败"
fi
done
mv "${local_folder}test1.txt" /root/test_cert
mv "${local_folder}test2.txt" /root/test_cert