本文共 3264 字,大约阅读时间需要 10 分钟。
使用批处理脚本上传ftp
Outside of email, probably the most common way to send files to a remote party is via FTP. While there are a plethora of FTP clients you can choose from, Windows has an little known and under utilized command line FTP utility built in. The beauty of this tool lies in it’s ability to be scripted which we have harnessed in the batch script below.
在电子邮件之外,最常见的将文件发送到远程方的方法是通过FTP。 尽管有很多FTP客户端供您选择,但Windows内置了一个鲜为人知且使用率不高的命令行FTP实用程序。此工具的优点在于它具有编写脚本的功能,我们已在下面的批处理脚本中加以利用。
This script can be used from the command line as a ‘no questions asked’ method of uploading one or many files with a single command. Additionally, you can call this script from batch files to perform automated file uploads. A few uses for this include (but, of course, not limited to):
可以从命令行使用此脚本作为“不问任何问题”的方法,通过一个命令即可上传一个或多个文件。 此外,您可以从批处理文件调用此脚本以执行自动文件上传。 此功能的一些用途包括(但不限于):
The only configuration required is to set the FTP server connection information. Under the “Connection information” line, set the following:
唯一需要的配置是设置FTP服务器连接信息。 在“连接信息”行下,进行以下设置:
Depending on your firewall settings, the first time you run this script you may be prompted to allow FTP to connect to the Internet. Setting this to never prompt you again should remove future warnings.
根据您的防火墙设置,首次运行此脚本时,系统可能会提示您允许FTP连接到Internet。 将此设置为从不再次提示您应删除以后的警告。
@ECHO OFFECHO Upload to FTPECHO Written by: Jason FaulknerECHO SysadminGeek.comECHO.ECHO.REM Usage:REM UploadToFTP [/L] FileToUploadREMREM Required Parameters:REM FileToUploadREM The file or file containing the list of files to be uploaded.REMREM Optional Parameters:REM /L When supplied, the FileToUpload is read as a list of files to be uploaded.REM A list of files should be a plain text file which has a single file on each line.REM Files listed in this file must specify the full path and be quoted where appropriate.SETLOCAL EnableExtensionsREM Connection information:SET Server=SET UserName=SET Password=REM ---- Do not modify anything below this line ----SET Commands="%TEMP%SendToFTP_commands.txt"REM FTP user name and password. No spaces after either.ECHO %UserName%> %Commands%ECHO %Password%>> %Commands%REM FTP transfer settings.ECHO binary >> %Commands%IF /I {%1}=={/L} ( REM Add file(s) to the list to be FTP'ed. FOR /F "usebackq tokens=*" %%I IN ("%~dpnx2") DO ECHO put %%I >> %Commands%) ELSE ( ECHO put "%~dpnx1" >> %Commands%)REM Close the FTP connection.ECHO close >> %Commands%ECHO bye >> %Commands%REM Perform the FTP.FTP -d -i -s:%Commands% %Server%ECHO.ECHO.REM Clean up.IF EXIST %Commands% DEL %Commands%ENDLOCAL
翻译自:
使用批处理脚本上传ftp
转载地址:http://nduwd.baihongyu.com/