用BAT使用FTP命令上传文件
上传文件
@ECHO OFF REM 注:不要添加非必要空格符 REM 目录文件 SET LOCAL_FILES=*.dll SET LOCAL_DIR="F:\workspace\Publish" REM 目录文件当前时间 SET FTP_FILE=FTP SET FTP_MKDIR=DIR_%DATE:~0,4%%DATE:~5,2%%DATE:~8,2% REM 基本信息 SET FTP_IP=192.168.1.2 SET FTP_PORT= SET FTP_USER_NAME=Anonymous SET FTP_PASSWORD=Anonymous SET FTP_PWD="/插件/Publish" REM 命令信息 ECHO OPEN %FTP_IP% %FTP_PORT%>%FTP_FILE% ECHO %FTP_USER_NAME%>>%FTP_FILE% ECHO %FTP_PASSWORD%>>%FTP_FILE% REM ECHO USER %FTP_USER_NAME% %FTP_PASSWORD%>>%FTP_FILE% REM 创建文件夹 REM ECHO PROMPT>>%FTP_FILE% ECHO CD %FTP_PWD%>>%FTP_FILE% ECHO MKDIR %FTP_MKDIR%>>%FTP_FILE% ECHO CD %FTP_MKDIR%>>%FTP_FILE% ECHO LCD %LOCAL_DIR%>>%FTP_FILE% REM 文件传输[二进制] ECHO BINARY>>%FTP_FILE% ECHO MPUT %LOCAL_FILES%>>%FTP_FILE% REM ECHO PUT %FILE0%>>%FTP_FILE% REM 退出 ECHO BYE>>%FTP_FILE% REM 执行文件 FTP -i -s:%FTP_FILE% REM 清理 DEL /Q %FTP_FILE% REM PAUSE
命令帮助
C:\Users>ftp ftp> ? 命令可能是缩写的。 命令为: ! delete literal prompt send ? debug ls put status append dir mdelete pwd trace ascii disconnect mdir quit type bell get mget quote user binary glob mkdir recv verbose bye hash mls remotehelp cd help mput rename close lcd open rmdir ftp> ? literal literal 发送任意 ftp 命令 ftp> ? remotehelp remotehelp 从远程服务器获取帮助 ftp>