博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用批处理脚本上传ftp_通过批处理脚本将文件上传到FTP站点
阅读量:2515 次
发布时间:2019-05-11

本文共 3264 字,大约阅读时间需要 10 分钟。

使用批处理脚本上传ftp

使用批处理脚本上传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):

可以从命令行使用此脚本作为“不问任何问题”的方法,通过一个命令即可上传一个或多个文件。 此外,您可以从批处理文件调用此脚本以执行自动文件上传。 此功能的一些用途包括(但不限于):

  • Include in backup scripts to send data offsite.

    包括在备份脚本中以将数据发送到异地。
  • Upload html/php/etc. files to a web server with a single command.

    上传html / php / etc。 使用一个命令将文件保存到Web服务器。
  • Create shortcuts to send a common group of files (such as a web site’s source pages).

    创建快捷方式以发送一组通用文件(例如网站的源页面)。

组态 (Configuration)

The only configuration required is to set the FTP server connection information. Under the “Connection information” line, set the following:

唯一需要的配置是设置FTP服务器连接信息。 在“连接信息”行下,进行以下设置:

  • Server – The FTP Server you are uploading to. You can either enter the DNS name (ftp.myserver.com) or IP address (1.2.3.4).

    服务器–您要上传到的FTP服务器。 您可以输入DNS名称(ftp.myserver.com)或IP地址(1.2.3.4)。
  • UserName – Your user name for connecting to FTP server.

    用户名–您用于连接FTP服务器的用户名。
  • Password – Your password for connecting to the FTP server.

    密码–您用于连接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。 将此设置为从不再次提示您应删除以后的警告。

剧本 (The Script)

@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

链接 (Links)

翻译自:

使用批处理脚本上传ftp

转载地址:http://nduwd.baihongyu.com/

你可能感兴趣的文章
Linux下Qt+CUDA调试并运行
查看>>
51nod 1197 字符串的数量 V2(矩阵快速幂+数论?)
查看>>
OKMX6Q在ltib生成的rootfs基础上制作带QT库的根文件系统
查看>>
zabbix
查看>>
多线程基础
查看>>
完美解决 error C2220: warning treated as error - no ‘object’ file generated
查看>>
使用SQL*PLUS,构建完美excel或html输出
查看>>
前后台验证字符串长度
查看>>
《算法导论 - 思考题》7-1 Hoare划分的正确性
查看>>
win64 Python下安装PIL出错解决2.7版本 (3.6版本可以使用)
查看>>
获取各种类型的节点
查看>>
表达式求值-201308081712.txt
查看>>
centos中安装tomcat6
查看>>
从Vue.js窥探前端行业
查看>>
学习进度
查看>>
poj3368 RMQ
查看>>
“此人不存在”
查看>>
github.com加速节点
查看>>
解密zend-PHP凤凰源码程序
查看>>
python3 序列分片记录
查看>>