简体   繁体   English

自动化批处理文件ftp下载

[英]Automating a batch file ftp download

Ok I have a pretty large batch program I am building to control power on over 100 DRAC ports and everything is built, tested, and working. 好的,我正在构建一个相当大的批处理程序,以控制100多个DRAC端口上的电源,并且一切都已构建,测试和运行。 However; 然而; I would like to have it automatically download plink.exe into the c:\\directory over ftp from the download website just by having coworkers answer either yes or no to a question regarding whether or not they have installed the program on their local machine so they don't have to browse for it. 我想让它自动地将plink.exe从下载网站下载到ftp上的c:\\目录中,方法是让同事回答有关他们是否已在本地计算机上安装程序的问题的是或否。不必浏览它。
Here is the section I've been working on: 这是我一直在努力的部分:

SET /p ANSWER=Have you downloaded plink.exe (Y/N)?
if /i {%ANSWER%}=={Y} (goto :Continue)
if /i {%ANSWER%}=={N} (goto :Download)
:Download
echo Starting Plink.exe download!!!
timeout /t 2
Site from which I will be downloading:
ftp://ftp.blahblahblah.com
:Continue

To automate commands to the built in ftp.exe on windows you have to store them in a seperate file 要在Windows上将命令自动执行到内置ftp.exe,必须将它们存储在单独的文件中

:start
SET /p ANSWER=Have you downloaded plink.exe (Y/N)?
if /i {%ANSWER%}=={Y} (goto :Continue)
if /i {%ANSWER%}=={N} (goto :Download)
goto start

:Download
echo Starting Plink.exe download!!!
rem timeout using ping command
PING 1.1.1.1 -n 1 -w 2000 >NUL

rem Write the commands - remove the ones you don't need, such as username and password
echo user USERNAME> ftpcmd.dat
echo PASSWORD>> ftpcmd.dat
echo bin>> ftpcmd.dat
echo get plink.exe>> ftpcmd.dat
echo quit>> ftpcmd.dat

rem run ftp command
ftp -n -s:ftpcmd.dat ftp.blahblahblah.com

rem delete the extra file.
del ftpcmd.dat

:Continue

Martyn 马丁

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM