Kyme Posted November 7, 2010 Share Posted November 7, 2010 (edited) hi guys, i have one old project of mine witch use ftp protocol my problem it's that ftpputfile not working, i'm under xp and i have read some topics and i guess this func not work under xp, can anybody tell my if it's possible to fix this somehow? or it's there some ftp udf working under xp? i mean to work the ftpputfile function everything it's ok in script, connection ok, but when it reach fileput it's upload me an file with 0kb thank you Edited November 7, 2010 by Kyme Link to comment Share on other sites More sharing options...
Developers Jos Posted November 7, 2010 Developers Share Posted November 7, 2010 Don't see a reason why wouldn't it work with winxp.. what is the problem? show some code. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Kyme Posted November 7, 2010 Author Share Posted November 7, 2010 (edited) Don't see a reason why wouldn't it work with winxp.. what is the problem? show some code. #include "FTP.au3" AutoItSetOption("TrayIconDebug",1) $server = 'xxx' $username = 'xxx' $pass = 'xxx' $Open = _FTPOpen('MyFTP Control') If $Open = 0 Then MsgBox(0,"FTP_Open Error",@error) Else MsgBox(0,"FTP Open completed","OK") EndIf $Conn = _FTPConnect($Open, $server, $username, $pass) If $Conn = 0 Then MsgBox(0,"FTP_Connect Error",@error) Else MsgBox(0,"FTP Connect completed","OK") EndIf $Ftpp = _FtpPutFile($Conn, 'C:\WINDOWS\Notepad.exe', 'notepad.exe') $Error = @error $lasterror = DllCall("kernel32.dll","int","GetLastError") msgbox(0,"LAST ERROR",$lasterror[0]) If $Ftpp = 0 Then MsgBox(0,"FTP_PutFile Error",$Error) Else MsgBox(0,"FTP Put completed","OK") EndIf $Ftpc = _FTPClose($Open) putfile return with 0 and heres putfile func Func _FTPPutFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 1, $l_Context = 1) Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpPutFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context) If @error OR $ai_FTPPutFile[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPPutFile[0] EndFunc ;==> _FTPPutFile() Edited November 7, 2010 by Kyme Link to comment Share on other sites More sharing options...
Developers Jos Posted November 7, 2010 Developers Share Posted November 7, 2010 Why are you not using the standard supplied udf's: #include <FTPEx.au3> $server = 'ftp.csx.cam.ac.uk' $username = '' $pass = '' $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, $username, $pass) ; ... $Ftpc = _FTP_Close($Open) The reason your current ftppufile doesn't work is because of the dllhandle. Something like this will probably work: #include <FTP.au3> $server = 'XX.XX.XXX.XX' $username = '*******' $pass = '**********' $dllhandle = DllOpen('wininet.dll') $Open = _FTPOpen('FTP-CyRius') $Conn = _FTPConnect($Open, $server, $username, $pass) MsgBox(0,"",$Conn) $Ftpp = _FtpPutFile($Conn,'file.ini') If @error Then MsgBox(0, "Error", @error) EndIf $Ftpc = _FTPClose($Open) DllClose($dllhandle) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Kyme Posted November 7, 2010 Author Share Posted November 7, 2010 (edited) Why are you not using the standard supplied udf's: #include <FTPEx.au3> $server = 'ftp.csx.cam.ac.uk' $username = '' $pass = '' $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, $username, $pass) ; ... $Ftpc = _FTP_Close($Open) The reason your current ftppufile doesn't work is because of the dllhandle. Something like this will probably work: #include <FTP.au3> $server = 'XX.XX.XXX.XX' $username = '*******' $pass = '**********' $dllhandle = DllOpen('wininet.dll') $Open = _FTPOpen('FTP-CyRius') $Conn = _FTPConnect($Open, $server, $username, $pass) MsgBox(0,"",$Conn) $Ftpp = _FtpPutFile($Conn,'file.ini') If @error Then MsgBox(0, "Error", @error) EndIf $Ftpc = _FTPClose($Open) DllClose($dllhandle) well...my script was made with standard func, using inclide FTPEx, but they don't work for me everything it's working until putfile, i wait long time to upload the file and when i look in host, file it's there, but 0kb all the time here's what i tried right now #include <FTPEx.au3> $server = 'xxx' $username = 'xxx' $pass = 'xxx' $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, $username, $pass) _FTP_FilePut($Conn, @ScriptDir&'\04112010013.jpg', '04112010013.jpg') $Ftpc = _FTP_Close($Open) same result...file in host exist, but 0kb exception on firewall added everything it's ok in that case, but still not working...i don't have any clue Edited November 7, 2010 by Kyme Link to comment Share on other sites More sharing options...
Developers Jos Posted November 7, 2010 Developers Share Posted November 7, 2010 It works when you try it from filezilla with the same userid and target server? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Fire Posted November 7, 2010 Share Posted November 7, 2010 (edited) Hi.Yes.Yet i have this trouble too.Believe me Windows Firewall cause it.Just execute firewall.cpl and add your application to trusted zone Apply-Ok and boom it gone.So if you script if not @compiled just add this to trusted zone in your Windows Firewall (%programfiles%\AutoIt3\AutoIt3.exe)(<=Browser for it and add)Can you see difference? (See below)Without trusted Application in standart windows FW.C:\Documents and Settings\user>ftp ftp> open 192.168.1.198 Связь с 192.168.1.198. 220 localftpserver FTP server (Version 6.00LS) ready. Пользователь (192.168.1.198:(none)): anonymous 331 Guest login ok, send your email address as password. Пароль: 230 Guest login ok, access restrictions apply. ftp> ls 200 PORT command successful. 425 Can't build data connection: Operation timed out. <<=== Can you see this? This is a reason for trouble.Also mget, mput didn't work in this situation. ftp>After :expandcollapse popupC:\Documents and Settings\user>ftp ftp> open 192.168.1.198 Связь с 192.168.1.198. 220 localftpserver FTP server (Version 6.00LS) ready. Пользователь (192.168.1.198:(none)): anonymous 331 Guest login ok, send your email address as password. Пароль: 230 Guest login ok, access restrictions apply. ftp> ls <====Now it successfull. 200 PORT command successful. 150 Opening ASCII mode data connection for 'file list'. bin etc pub incoming incoming0 226 Transfer complete. ftp: 36 байт получено за 0,00 (сек) со скоростью 36000,00 (КБ/сек). ftp> dir 200 PORT command successful. 150 Opening ASCII mode data connection for '/bin/ls'. total 10 dr-xr-xr-x 2 0 5 512 Jun 27 2003 bin d--------- 2 0 5 512 Jun 27 2003 etc drwxr-xr-x 6 0 0 512 Oct 1 13:27 incoming drwxr-xr-x 8 0 5 512 Oct 1 13:27 incoming0 drwxr-xr-x 27 1004 0 1024 Nov 23 2009 pub 226 Transfer complete. ftp: 256 байт получено за 0,02 (сек) со скоростью 16,00 (КБ/сек). ftp> pwd 257 "/" is current directory. ftp> pwd 257 "/" is current directory. ftp> ls -tla 200 PORT command successful. 150 Opening ASCII mode data connection for '/bin/ls'. total 14 drwxr-xr-x 6 0 0 512 Oct 1 13:27 incoming drwxr-xr-x 8 0 5 512 Oct 1 13:27 incoming0 dr-xr-xr-x 7 0 5 512 Oct 1 13:26 .. dr-xr-xr-x 7 0 5 512 Oct 1 13:26 . drwxr-xr-x 27 1004 0 1024 Nov 23 2009 pub d--------- 2 0 5 512 Jun 27 2003 etc dr-xr-xr-x 2 0 5 512 Jun 27 2003 bin 226 Transfer complete. ftp: 347 байт получено за 0,01 (сек) со скоростью 23,13 (КБ/сек). ftp> mget pub/rfc/rfc999.txt 200 Type set to A. mget rfc999.txt? Y 200 PORT command successful. 150 Opening ASCII mode data connection for 'rfc999.txt' (61584 bytes). 226 Transfer complete. ftp: 62877 байт получено за 0,58 (сек) со скоростью 108,60 (КБ/сек). ftp> bye 221 Goodbye.Now it is sucessfull.Add your application (if compiled) to Windows Firewalls Exception.If not your script compiled add whole %programfiles%\AutoIt3\AutoIt3.exe to Windows Firewalls Exception.I hope this will solve your problem;) Edited November 7, 2010 by Fire [size="5"] [/size] Link to comment Share on other sites More sharing options...
Kyme Posted November 8, 2010 Author Share Posted November 8, 2010 Hi. Yes.Yet i have this trouble too. Believe me Windows Firewall cause it. Just execute firewall.cpl and add your application to trusted zone Apply-Ok and boom it gone. So if you script if not @compiled just add this to trusted zone in your Windows Firewall (%programfiles%\AutoIt3\AutoIt3.exe)(<=Browser for it and add) Can you see difference? (See below) Without trusted Application in standart windows FW. C:\Documents and Settings\user>ftp ftp> open 192.168.1.198 Связь с 192.168.1.198. 220 localftpserver FTP server (Version 6.00LS) ready. Пользователь (192.168.1.198:(none)): anonymous 331 Guest login ok, send your email address as password. Пароль: 230 Guest login ok, access restrictions apply. ftp> ls 200 PORT command successful. 425 Can't build data connection: Operation timed out. <<=== Can you see this? This is a reason for trouble.Also mget, mput didn't work in this situation. ftp> After : expandcollapse popupC:\Documents and Settings\user>ftp ftp> open 192.168.1.198 Связь с 192.168.1.198. 220 localftpserver FTP server (Version 6.00LS) ready. Пользователь (192.168.1.198:(none)): anonymous 331 Guest login ok, send your email address as password. Пароль: 230 Guest login ok, access restrictions apply. ftp> ls <====Now it successfull. 200 PORT command successful. 150 Opening ASCII mode data connection for 'file list'. bin etc pub incoming incoming0 226 Transfer complete. ftp: 36 байт получено за 0,00 (сек) со скоростью 36000,00 (КБ/сек). ftp> dir 200 PORT command successful. 150 Opening ASCII mode data connection for '/bin/ls'. total 10 dr-xr-xr-x 2 0 5 512 Jun 27 2003 bin d--------- 2 0 5 512 Jun 27 2003 etc drwxr-xr-x 6 0 0 512 Oct 1 13:27 incoming drwxr-xr-x 8 0 5 512 Oct 1 13:27 incoming0 drwxr-xr-x 27 1004 0 1024 Nov 23 2009 pub 226 Transfer complete. ftp: 256 байт получено за 0,02 (сек) со скоростью 16,00 (КБ/сек). ftp> pwd 257 "/" is current directory. ftp> pwd 257 "/" is current directory. ftp> ls -tla 200 PORT command successful. 150 Opening ASCII mode data connection for '/bin/ls'. total 14 drwxr-xr-x 6 0 0 512 Oct 1 13:27 incoming drwxr-xr-x 8 0 5 512 Oct 1 13:27 incoming0 dr-xr-xr-x 7 0 5 512 Oct 1 13:26 .. dr-xr-xr-x 7 0 5 512 Oct 1 13:26 . drwxr-xr-x 27 1004 0 1024 Nov 23 2009 pub d--------- 2 0 5 512 Jun 27 2003 etc dr-xr-xr-x 2 0 5 512 Jun 27 2003 bin 226 Transfer complete. ftp: 347 байт получено за 0,01 (сек) со скоростью 23,13 (КБ/сек). ftp> mget pub/rfc/rfc999.txt 200 Type set to A. mget rfc999.txt? Y 200 PORT command successful. 150 Opening ASCII mode data connection for 'rfc999.txt' (61584 bytes). 226 Transfer complete. ftp: 62877 байт получено за 0,58 (сек) со скоростью 108,60 (КБ/сек). ftp> bye 221 Goodbye. Now it is sucessfull. Add your application (if compiled) to Windows Firewalls Exception. If not your script compiled add whole %programfiles%\AutoIt3\AutoIt3.exe to Windows Firewalls Exception. I hope this will solve your problem;) i fix it in other way, the problem was on connection/putfile flags here's how i fix it #include <FTPEx.au3> $server = 'xxxx' $username = 'xxx' $pass = 'xxx' $Open = _FTP_Open('MyFTP Control') $Conn = _FTPConnect($Open, $server, $username, $pass,0,1,0x08000000) $Ftpp = _FtpPutFile($Conn,"C:\xxx.jpg", '/xxx.jpg' , 0x08000000) Func _FTPConnect($l_InternetSession, $s_ServerName, $s_Username, $s_Password, $i_ServerPort = 0, $l_Service = 1, $l_Flags = 0, $l_Context = 0) Local $ai_InternetConnect = DllCall('wininet.dll', 'long', 'InternetConnect', 'long', $l_InternetSession, 'str', $s_ServerName, 'int', $i_ServerPort, 'str', $s_Username, 'str', $s_Password, 'long', $l_Service, 'long', $l_Flags, 'long', $l_Context) If @error OR $ai_InternetConnect[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_InternetConnect[0] EndFunc Func _FtpPutFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0) Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpPutFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context) If @error OR $ai_FTPPutFile[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPPutFile[0] EndFunc at me firewall was 100% not problem, because i try it firewall off and same result, i add those flags and it's worked i found this in forum, thanks to the forums members i fixed this Regards Skeletor 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now