liangxm 发表于 2011-11-23 12:32:56

ftp内外网问题

本帖最后由 liangxm 于 2011-11-23 12:36 编辑

#include <FTPEx.au3>
$server = '10.2.10.7';服务器
$name = 'test'            ;用户名
$pass = '123456'            ;密码
$s_LocalFile = "D:\ITS\liangxm.txt"                        ;本地上传文件
$s_RemoteFile = "\liangxm.txt"                        ;上传服务器文件

$nSize = InetGetSize("ftp://test:123456@10.2.10.7/1.txt")
MsgBox(0,"提示框","文件大小:" & $nSize)

;$nSize = InetGetSize("ftp://test:123456@10.2.10.7/1.txt")
;MsgBox(0,"提示框","文件大小:" & $nSize)

$Open = _FTP_Open('MyFTP');打开一个FTP会话
$Conn = _FTP_Connect($Open,$server,$name,$pass);连接到ftp服务器

MsgBox(0,"连接",$Conn)

$ftp_upload = _FTP_FilePut($Conn,$s_LocalFile,$s_RemoteFile);上传文件
;$ftp_upload = _FTP_FilePut($Conn,"D:\ITS\liangxm.txt","\Remote Debugger\liangxm.txt");上传文件

MsgBox(0,"上传",$ftp_upload)

$Ftpc = _FTP_Close($Open);关闭 _FTP_Open 打开的回话


------------------------------------------------------------------------------------------------------------

测了一下,内网ftp没有问题,把ip,账号,密码换成外网的就有问题了:
InetGetSize()取不到大小
Conn = _FTP_Connect不为0,说明账号密码应该没有问题,已经连上ftp了
$ftp_upload = _FTP_FilePut这个一直0,说明没有上传成功/连另一个外网ftp直接运行到此卡住不动


不知道这样内网ftp可以,外网ftp不行一般问题会出现在哪?好像这个也没有多的什么返回值,debug信息,不知道是哪里的问题。

amxi 发表于 2011-11-23 13:59:27

InetGetSize要头文件 <IE.au3>

amxi 发表于 2011-11-23 14:00:56

外网ftp测试成功...

liangxm 发表于 2011-11-23 14:52:56

InetGetSize要头文件
amxi 发表于 2011-11-23 13:59 http://www.autoitx.com/images/common/back.gif


    试过内网,不加也可以的

liangxm 发表于 2011-11-23 14:53:59

外网ftp测试成功...
amxi 发表于 2011-11-23 14:00 http://www.autoitx.com/images/common/back.gif


    你把代码换成你的外网ftp可以用吗?
难道是我rpwt?还是我的ftp哪里设置有问题?我用工具连,操作都没问题,用au3代码就不行

liangxm 发表于 2011-11-23 17:21:42

本帖最后由 liangxm 于 2011-11-23 17:56 编辑

(000062)2011-11-23 17:19:33 - (not logged in) (110.86.14.98)> USER ad
(000062)2011-11-23 17:19:33 - (not logged in) (110.86.14.98)> 331 Password required for ad
(000062)2011-11-23 17:19:33 - (not logged in) (110.86.14.98)> PASS ******
(000062)2011-11-23 17:19:33 - ad (110.86.14.xx)> 230 Logged on
(000062)2011-11-23 17:19:34 - ad (110.86.14.xx)> TYPE I
(000062)2011-11-23 17:19:34 - ad (110.86.14.xx)> 200 Type set to I
(000062)2011-11-23 17:19:34 - ad (110.86.14.xx)> PORT 10,2,10,7,239,175
(000062)2011-11-23 17:19:34 - ad (110.86.14.xx)> 200 Port command successful
(000062)2011-11-23 17:19:34 - ad (110.86.14.xx)> STOR liangxm.txt
(000062)2011-11-23 17:19:34 - ad (110.86.14.xx)> 150 Opening data channel for file transfer.
(000062)2011-11-23 17:19:44 - ad (110.86.14.xx)> 425 Can't open data connection.

服务器上日志,百度了一下,估计是防火墙,ftp服务器设置,主动被动模式的问题,不知道有没有什么办法呢?

liangxm 发表于 2011-11-23 17:57:38

[ INFO] 2011-11-23 17:39:00,198 RECEIVED: STOR /update.xx.com/liangxm.txt
[ WARN] 2011-11-23 17:39:44,199 FtpDataConnection.getDataSocket()
[ INFO] 2011-11-23 17:39:44,200 SENT: 150 File status okay; about to open data connection.
页: [1]
查看完整版本: ftp内外网问题