在window运行指定x分钟,用ftpd上传本机指定目录里的x文件到centos服务器的指定目录里的bat方法
上传指定文件的方法:
@echo off
setlocal
rem 设置上传参数
set "local_path=c:\files\file.txt"
set "remote_path=/home/user/files/file.txt"
set "server_ip=192.168.1.100"
set "username=ftpuser"
set "password=ftpp❌❌❌word"
rem 设置循环时间(单位:秒)
set "loop_time=300"
rem 无限循环上传文件
:loop
timeout /t %loop_time%
echo uploading file %local_path% to %server_ip%:%remote_path%
echo user %username% %password% > ftp_commands.txt
echo bin >> ftp_commands.txt
echo cd %remote_path% >> ftp_commands.txt
echo put %local_path% >> ftp_commands.txt
echo bye >> ftp_commands.txt
ftp -n -s:ftp_commands.txt %server_ip%
del ftp_commands.txt
echo file uploaded successfully.
goto loop
endlocal
上传指定目录内的文件的方法:
@echo off
setlocal
rem 设置上传参数
set "local_folder=c:\files"
set "remote_folder=/home/user/files"
set "server_ip=192.168.1.100"
set "username=ftpuser"
set "password=ftpp❌❌❌word"
rem 设置循环时间(单位:秒)
set "loop_time=300"
rem 无限循环上传文件
:loop
timeout /t %loop_time%
for %%f in ("%local_folder%\*.*") do (
echo uploading file %%~nxf to %server_ip%:%remote_folder%
echo user %username% %password% > ftp_commands.txt
echo bin >> ftp_commands.txt
echo cd %remote_folder% >> ftp_commands.txt
echo put "%%f" >> ftp_commands.txt
echo bye >> ftp_commands.txt
ftp -n -s:ftp_commands.txt %server_ip%
del ftp_commands.txt
echo file uploaded successfully.
)
goto loop
endlocal
评论前必须登录!
注册