首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我的FTP批处理脚本卡在"200端口命令成功“上,没有将文件上传到服务器

我的FTP批处理脚本卡在"200端口命令成功“上,没有将文件上传到服务器
EN

Stack Overflow用户
提问于 2015-06-02 08:48:17
回答 2查看 37.8K关注 0票数 12

我试过我在谷歌搜索结果中找到的关于

200端口命令成功

但什么都帮不上忙。

有人能帮忙解决这个问题吗?

代码"runScript.bat:

代码语言:javascript
复制
ftp -s:"C:\automation\fileup.bat" myserver.com

代码"fileup.bat:

代码语言:javascript
复制
username
password
ascii
cd "/public_html/reports/"
lcd "C:\automation\tests\HtmlReporter"
prompt
mput *
disconnect
close
bye

控制台日志:

代码语言:javascript
复制
C:\automation>ftp -s:"C:\automation\fileup.bat" myserver.com
Connected to myserver.com.
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 7 of 500 allowed.
220-Local time is now 04:40. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 3 minutes of inactivity.
User (server26.000webhost.com:(none)):
331 User username OK. Password required

230-OK. Current restricted directory is /
230-449 files used (4%) - authorized: 10000 files
230 16742 Kbytes used (1%) - authorized: 1536000 Kb
ftp> ascii
200 TYPE is now ASCII
ftp> cd "/public_html/reports/"
250 OK. Current directory is /public_html/reports
ftp> lcd "C:\automation\tests\HtmlReporter"
Local directory now C:\automation\tests\HtmlReporter.
ftp> prompt
Interactive mode Off .
ftp> mput *
200 PORT command successful
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-06-02 11:34:50

这看起来像是FTP活动模式的一个典型问题。服务器无法连接到您的计算机以建立数据传输连接。

这种情况通常发生在现在大多数客户端计算机都在防火墙或NAT后面,或者两者都在后面,这是FTP活动模式无法工作的原因。要使活动模式正常工作,您需要打开防火墙(不推荐)和/或配置NAT路由规则。

请参阅我在FTP模式和为活动模式配置网络上的文章。

或者使用被动FTP模式。不过,Windows ftp.exe客户端不支持被动模式,这使得它现在变得非常无用。

因此,您需要使用另一个命令行FTP客户端。大多数FTP客户端确实支持被动模式。

例如,使用WinSCP,您的runScript.bat将类似于:

代码语言:javascript
复制
winscp.com /command ^
    "open ftp://username:password@myserver.com/" ^
    "cd /public_html/reports/" ^
    "lcd C:\automation\tests\HtmlReporter" ^
    "put *" ^
    "exit"

注意,WinSCP默认为被动模式。

有关详细信息,请参阅WinSCP指南:

(我是WinSCP的作者)

票数 23
EN

Stack Overflow用户

发布于 2016-10-28 04:10:22

我也遇到了同样的问题("200端口命令成功“永远挂在屏幕上),并且我能够解决它。

首先,互联网上有很多帖子说Windows ftp.exe不支持被动模式。但事实并非如此:

ftp>报价pasv

227进入被动模式

在我的例子中,我有一个带有真正IP的Windows2012 R2服务器。切换到被动模式并没有解决问题,我仍然停留在"200端口指挥成功“。同时,WinSCP工作得很好。解决方案是创建一个入站防火墙规则,允许从FTP服务器到本地ftp.exe的外部连接。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30591387

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档