我有这个脚本来压缩文件并通过ftp发送,除非我更改默认端口,否则效果很好。
我有这个:
SET ftphost=xx.xxx.xxx.xx
并想添加一个端口。我试过这个: ipadress后跟一个空格和端口,但我得到了帮助内容而不是连接。
SET ftphost=xx.xxx.xxx.xx 999
并使用冒号而不是空格和端口,我得到“未知主机”
SET ftphost=xx.xxx.xxx.xx:999
这是洞脚本
REM ECHO year=%year%
SET month=%date:~5,2%
IF "%month:~0,1%" == " " SET month=0%month:~1,1%
REM ECHO month=%month%
SET day=%date:~8,2%
IF "%day:~0,1%" == " " SET day=0%day:~1,1%
REM ECHO day=%day%
REM set filename with current timestamp
SET filename=file_%year%%month%%day%_%hour%%min%%secs%.zip
REM to ask to set zip password
REM SET /p zippass=Set zip password:
REM to set the zip password instead of asking for it
SET zippass="p"
REM to ask for parameters
REM SET /p ftphost=Enter ftphost:
REM SET /p username=Enter user:
REM SET /p userpass=Enter password:
REM to save the parameters instead of asking for them
SET ftphost=xx.xxx.xxx.xx
SET username=all
SET userpass=12345
SET encrypt_headers=
REM SET encrypt_headers=-mhe
START /wait 7za.exe a %filename% * -r -mx9 -p%zippass% %encrypt_headers% -x!7za.exe -x!zip_ftp.bat -x!zip_ftp_ask.bat
SET file=%filename%
@ECHO off
ECHO user %username%> ftpcmd.dat
ECHO %userpass%>> ftpcmd.dat
ECHO bin>> ftpcmd.dat
ECHO put %file%>> ftpcmd.dat
ECHO quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat %ftphost%
DEL ftpcmd.dat
PAUSE
是否有不同的sintax或参数将端口添加到ftp?
答案 0 :(得分:0)
正如Matt Williamson所说,将端口open 172.xx.xx.xx 22 > ftpcmd.dat
的命令open host添加到解决方案中,不知道为什么它无法直接从脚本中读取地址。
以下是脚本的工作ftp部分:
SET ftphost=172.xxx.xxx.xx 22
ECHO open %ftphost% > ftpcmd.dat
ECHO user %username%>> ftpcmd.dat
ECHO %userpass%>> ftpcmd.dat
ECHO bin>> ftpcmd.dat
ECHO put %file%>> ftpcmd.dat
ECHO quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat
PAUSE
这应该避免窗口显示ftp的帮助内容而不是尝试连接。