优质VPS推荐
VPS优惠 评测

在window用ftpd上传本机x文件到centos服务器的指定目录的方法

在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
赞(0) 打赏
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《在window用ftpd上传本机x文件到centos服务器的指定目录的方法》
文章链接:https://www.tianyanjie.com/1741.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

评论 抢沙发

评论前必须登录!

 

登录

找回密码

注册