自动化批处理文件ftp下载

时间:2013-07-29 20:20:13

标签: batch-file ftp

好的我有一个非常大的批处理程序,我正在构建以控制超过100个DRAC端口的电源,所有内容都已构建,测试和工作。然而;我想让它自动从下载网站下载plink.exe进入ftp的c:\目录,只需让同事回答是或否回答关于他们是否在本地机器上安装了程序的问题,这样他们就可以了不必浏览它 以下是我一直在研究的部分:

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

1 个答案:

答案 0 :(得分:0)

要在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

马丁