sbgwb0769 Posted June 10, 2008 Share Posted June 10, 2008 (edited) Good! Thank you very much! Edited June 10, 2008 by sbgwb0769 Link to comment Share on other sites More sharing options...
Zedna Posted June 10, 2008 Share Posted June 10, 2008 Hi all: I am using UDF FTP.au3, to upload a text file from windows Xp sp2 to unix ftp server, the scrip is running well but I found a BIG PROBLEM, maybe a BUG in FTP.au3 when the file test.txt is uploaded, the file was changed and added a carriage return(CR) and a line feed (LF) for , for each line . Someone can tell me what is wrong with my script or is a FTP.au3 BUG? Please I need a HELP on this ? CR=carriage return LF=Line feed For example , original file test.txt looks like this: aaaaaaaaaaaaabbbbbbbbb123456CR bbbbbbbbbbbbbbbbbbbbbbbbbbbbCR ddddddddddddddddddddddddddddCR The new uploaded file test.txt looks like this (Inserted CR and LF for each line): aaaaaaaaaaaaabbbbbbbbbccccccCR CR LFbbbbbbbbbbbbbbbbbbbbbbbbbbbbCR CR LFddddddddddddddddddddddddddddCR Try to set explicit flag value to $INTERNET_FLAG_TRANSFER_BINARY in _FtpPutFile() Global Const $INTERNET_FLAG_PASSIVE = 0x08000000 Global Const $INTERNET_FLAG_TRANSFER_ASCII = 0x00000001 Global Const $INTERNET_FLAG_TRANSFER_BINARY = 0x00000002 Dim $Ftpp = _FtpPutFile($Conn, 'C:\TEMP\test.txt', '/test.txt', $INTERNET_FLAG_TRANSFER_BINARY) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Azazash Posted June 13, 2008 Share Posted June 13, 2008 (edited) I am having a strange problem with the FTP UDF and i can for the life of me find out why it is happening. I have a script that is supposed to scan a folder for any file beginning with the letter L and upload it to our FTP server. However it seems to only copy 1 of the 7 files it is supposed to be sending. My code is as follows. expandcollapse popup#include <FTP.au3> #Region FTP Upload $fFTPUpload = GUICreate("",$fWidth, $lHeight, -1, -1,$WS_POPUP + $WS_BORDER,-1,$maintenance) $bSave = GUICtrlCreateButton("Upload",315,200, 75, 25, 0) GUICtrlSetOnEvent(-1,"FTPStart") $file = FileOpen(@scriptdir&"\Install\Lexacom.ini",0) $ftPath= FileReadLine($file,3) FileClose($file) $files = _FileListToArray($ftPath,'L*',1) GUICtrlCreateGroup("",5,0,400,240) #endregion #region FTP Upload Funcs Func FTPStart() Dim $server = "xxxx" Dim $username = "xxxx" Dim $pass = "xxxx" Dim $port = 21 Dim $dllhandle = DllOpen('wininet.dll') Dim $Open = _FTPOpen('MyFTP') Dim $Conn = _FTPConnect($Open, $server, $username, $pass, $port) Global Const $INTERNET_FLAG_PASSIVE = 0x08000000 Global Const $INTERNET_FLAG_TRANSFER_ASCII = 0x00000001 Global Const $INTERNET_FLAG_TRANSFER_BINARY = 0x00000002 if @error Then MsgBox(0,"Error", "No files were found",5) EndIf for $i = 1 to $files[0] Dim $Ftpp = _FtpPutFile($Conn, $files[$i], '/httpdocs/incoming/'&$Company&' - '&$serial&' - '&$files[$i], $INTERNET_FLAG_TRANSFER_BINARY) ConsoleWrite($files[$i]&' - '&$ftpp&@crlf) sleep(500) Next ;~ ---------------------------------- $lasterror = DllCall("kernel32.dll","int","GetLastError") ConsoleWrite("LAST ERROR - "&$lasterror[0]) ;~ ---------------------------------- Dim $Ftpc = _FTPClose($Open) DllClose($dllhandle) EndFunc #endregion The Console output for the transfer is as follows: LCLinks.lxd - 0 LCPools.lxd - 0 LCRegist.lxd - 0 LCSeats.lxd - 0 LCSeats.pln - 1 LCUsers.lxd - 0 LexClients.lxd - 0 LexConfigSys.lxd - 0 LAST ERROR - 0+>13:13:43 AutoIT3.exe ended.rc:0 As you can see the *.pln file is reporting something happening, which i can only assume means success, as the pln file does get uploaded, and the others fail. Can anyone point me in the right direction for this as its proving to be a right hair puller Edited June 13, 2008 by Azazash Link to comment Share on other sites More sharing options...
martin Posted June 14, 2008 Share Posted June 14, 2008 I am having a strange problem with the FTP UDF and i can for the life of me find out why it is happening. .. Can anyone point me in the right direction for this as its proving to be a right hair puller $files will only contain the file names. In _FtpPutFile you need to give the full path. $ftPath & "\" & $files[$i] Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Azazash Posted June 17, 2008 Share Posted June 17, 2008 Thanks you are absolutely right... I guess i couldn't see the wood for the trees A secondary issue i have is that i want to be able to upload 7 files, which are unique to a particular site, to its own individual folder. Uploading files is fine (now thanks to martin) but i can't find any info about creating directories on an FTP server using the FTP UDF or any other way of doing it. Is it possible to do or should i just abandon that idea? Link to comment Share on other sites More sharing options...
Zedna Posted June 17, 2008 Share Posted June 17, 2008 Thanks you are absolutely right... I guess i couldn't see the wood for the trees A secondary issue i have is that i want to be able to upload 7 files, which are unique to a particular site, to its own individual folder. Uploading files is fine (now thanks to martin) but i can't find any info about creating directories on an FTP server using the FTP UDF or any other way of doing it. Is it possible to do or should i just abandon that idea? ;=============================================================================== ; ; Function Name: _FTPMakeDir() ; Description: Makes an Directory on an FTP server. ; Parameter(s): $l_FTPSession - The Long from _FTPConnect() ; $s_Remote - The directory name to be created. ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): Wouter van Kesteren ; ;=============================================================================== Func _FTPMakeDir($l_FTPSession, $s_Remote) Local $ai_FTPMakeDir = DllCall('wininet.dll', 'int', 'FtpCreateDirectory', 'long', $l_FTPSession, 'str', $s_Remote) If @error OR $ai_FTPMakeDir[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPMakeDir[0] EndFunc ;==> _FTPMakeDir() Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Colin Posted July 18, 2008 Share Posted July 18, 2008 (edited) Hi, I've read through this entire topic, and I'm having trouble with _FtpGetFile(). Basically, what happens is that it runs, but no file is retrieved. It does set @error = 1, so I assume there is a problem there somehow. The _FtpOpen() and _FtpConnect() commands work fine without error. Also, the _FtpPutFile() seems to work fine. So I'm pretty sure it's something with the Get function. One specific question, if the local file or directory that I want the file to be placed in does not exist, will it be created automatically? Also, in the _FtpGetFile() command, the parameter for the remote file to retrieve, does the path have to be the full path? As in, "ftp://ftp.domain.com/directory/file.txt" or can I just do "/directory/file.txt". I've tried it both ways, so I don't think that's my problem, but I wanted to make sure. Thanks in advance! Code to follow: #include <FTP.au3> Local $sDomain = "ftp.domain.com" Local $sUser = "user" Local $sPassword = "pass" Local $sRemoteDir = "/remotedir/" Local $sFile = "file.txt" Local $sLocalDir = @MyDocumentsDir & "\localdir\" $dllhandle = DllOpen("wininet.dll") $Open = _FTPOpen("ftp") If @error Then MsgBox(1, "", "Unable to Connect.") Exit EndIf $Conn = _FTPConnect($Open, $sDomain, $sUser, $sPassword) If @error Then MsgBox(1, "", "Unable to Connect.") Exit EndIf $Ftpg = _FtpGetFile($Conn, "ftp://" & $sDomain & $sRemoteDir & $sFile, $sLocalDir & $sFile) If @error Then MsgBox(1, "", "File Not Retrieved") Exit EndIf $Ftpc = _FTPClose($Open) DllClose($dllhandle) Edit: While I'm at it, I'm also attempting to use _FTPOpenFile(), _FTPReadFile(), and _FTPCloseFile() to bypass the need for _FTPGetFile(). Plus it might be cool to not have to download a temp file just so I can read it and then delete it afterwards. Anyways, I'm getting an error on the _FTPReadFile() command. Also, I'm looking at what the actual contents of that variable returns and it's just 0. Not sure what I'm doing wrong really... So here's the code: expandcollapse popup#include <FTP.au3> Local $sDomain = "ftp.domain.com" Local $sUser = "user" Local $sPassword = "pass" Local $sRemoteDir = "/remotedir/" Local $sFile = "file.txt" Local $sLocalDir = @MyDocumentsDir & "\localdir\" $dllhandle = DllOpen("wininet.dll") $Open = _FTPOpen("ftp") If @error Then MsgBox(1, "", "Unable to Connect.") Exit EndIf $Conn = _FTPConnect($Open, $sDomain, $sUser, $sPassword) If @error Then MsgBox(1, "", "Unable to Connect.") Exit EndIf $FileToRead = _FTPOpenFile($Open, $sRemoteDir & $sFile) If @error Then MsgBox(1, "", "File open failed.") Exit EndIf $ReadFile = _FTPReadFile($FileToRead, 5000) if @error Then MsgBox(1, "", "File read failed.") Exit EndIf _FTPCloseFile($FileToRead) MsgBox(1, "", $ReadFile) $Ftpc = _FTPClose($Open) DllClose($dllhandle) Thanks again! Edited July 18, 2008 by Colin Link to comment Share on other sites More sharing options...
martin Posted July 19, 2008 Share Posted July 19, 2008 (edited) One specific question, if the local file or directory that I want the file to be placed in does not exist, will it be created automatically?No.Also, in the _FtpGetFile() command, the parameter for the remote file to retrieve, does the path have to be the full path? As in, "ftp://ftp.domain.com/directory/file.txt" or can I just do "/directory/file.txt". I've tried it both ways, so I don't think that's my problem, but I wanted to make sure.Use the full path, or you can use _FtpSetCurrentDir if you have that function and then you only need to give the file names to copy.Where do the functions_FTPOpenFile, _FTPReadFile and _FTPCloseFile come from? I don't see them in the ftp.au3 file in the first post.Normally (?) you would use _FTPOpenFile then InternetReadFile then InternetCloseHandleI think it's easier to use _FTPGetFile and read it locally. Edited July 19, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Colin Posted July 21, 2008 Share Posted July 21, 2008 Thanks for the response.Here's the post where I found the functions for open/read/close (it's one of the posts in this topic I believe):http://www.autoitscript.com/forum/index.ph...st&p=331340and this is an update to the read function (I'm using this version, not the original one):http://www.autoitscript.com/forum/index.ph...st&p=332525And yea, I would just use the FTPGetFile() function if I could get it to work. The only reason I tried the open/read/close method is to see if it would even work. Any idea why the Get function isn't working for me? Link to comment Share on other sites More sharing options...
Cedric7634 Posted July 23, 2008 Share Posted July 23, 2008 hi muttley there is anyone who use this to make a content uploader(master)/downloader(client)? could be very usefull for me thanks, Cedric Link to comment Share on other sites More sharing options...
martin Posted July 23, 2008 Share Posted July 23, 2008 Thanks for the response. Here's the post where I found the functions for open/read/close (it's one of the posts in this topic I believe): http://www.autoitscript.com/forum/index.ph...st&p=331340 and this is an update to the read function (I'm using this version, not the original one): http://www.autoitscript.com/forum/index.ph...st&p=332525 And yea, I would just use the FTPGetFile() function if I could get it to work. The only reason I tried the open/read/close method is to see if it would even work. Any idea why the Get function isn't working for me?I didn't look at the links you gave yet, but here is a script which should get you started using FTPGetFile expandcollapse popup#include <ftp.au3>;or whatever udf you use Global $server, $username, $pass, $connected = False, $filetoget, $LFolder, $hDll Global $waytodoit = 1;<-------------1 or not 1 to use setting full remote path or not ;add your details $server = '*********' $username = '*********' $pass = '*********' $LFolder = @ScriptDir;<--------- set the folder you want the file copied to on your PC $Open = _FTPOpen('MyFTP Control') If @error = -1 Then MsgBox(0, 'error', 'Open failed') Exit EndIf $Conn = _FTPConnect($Open, $server, $username, $pass, 0, 1, 0x08000000) If @error = -1 Then MsgBox(0, 'error', 'Connect failed') Exit EndIf $connected = True $RFolder = _FtpGetCurrentDir($Conn) ConsoleWrite("Current remote folder is " & $RFolder & @CRLF) $RFolder = "/foldername";$RFolder;<---------change to the folder you want $filetoget = "fileName.HTML";somename.abc";<-----add the name of the file you want to copy. Don't forget that the names will probably be case sensitive! If $waytodoit = 1 Then If _FtpSetCurrentDir($Conn, $RFolder) = 0 Then MsgBox(0, 'Could not log to..', $RFolder) Exit EndIf If _FTPGetFile($Conn, $filetoget, $LFolder & '\' & $filetoget) = 0 Then;'/' & $Rfolder & MsgBox(0, 'Error', 'Failed to get ' & $filetoget) EndIf Else If _FTPGetFile($Conn, $RFolder & '/' & $filetoget, $LFolder & '\' & $filetoget) = 0 Then;'/' & $Rfolder & MsgBox(0, 'Error', 'Failed to get ' & $RFolder & '/' & $filetoget) EndIf EndIf ;########### end Func onautoitstart() $hDll = DllOpen("Wininet.dll");have to do this for the ftp routines to work If $hDll = -1 Then MsgBox(0, 'Error', 'Could not open WIninet.dll') EndIf EndFunc ;==>onautoitstart Func onAutoitExit() If $connected Then _FTPClose($Open) If $hDll <> 0 Then DllClose($hDll) EndFunc ;==>onAutoitExit Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Colin Posted July 24, 2008 Share Posted July 24, 2008 (edited) Thanks again for the response. I attempted to implement some of your methods into my current script, and I'm getting "autoit3.exe has encountered a problem and needs to close." I tried running another script (one that uses the same #include file, and connects to the same FTP server) and it runs just fine. I also tried grabbing the exact code you posted and changing just the server/login variables, and the remote directory and file name variables. When I run that, I get the same error. There's something in that code that is different from how my other FTP script works that's causing a problem, but I can't seem to figure out what it is. Again, thank you for the help. It's much appreciated. Edit: I have a question about something. When I do the @error check after using _FTPOpen() or _FTPConnect(), what value does @error have when it fails? In my script, I'm checking (If @error Then) and considering that a fail. In martin's script, he is using (If @error = -1 Then) as the fail. Which one is correct, or does it matter? Edit again: It seems as though the issue was with _FtpGetCurrentDir(). As soon as I removed the functionality that uses that, it actually worked. That error stopped coming up, and... I actually GOT THE FILE!! Yay! Thanks for pointing me in the right direction Martin. I'm still not sure what I was doing wrong before, but at least I should be able to implement this code into my other script so that the Get will work. It would be nice to figure out why the _FtpGetCurrentDir() doesn't work too, but I don't think I'll need that for any reason. I will just tell the script what directory to use. Thanks again! Edited July 26, 2008 by Colin Link to comment Share on other sites More sharing options...
Cedric7634 Posted August 4, 2008 Share Posted August 4, 2008 hi there is anyone who use this to make a content uploader(master)/downloader(client)?could be very usefull for me thanks,CedricNoone? Really? Link to comment Share on other sites More sharing options...
JohnMC Posted August 15, 2008 Share Posted August 15, 2008 Noone? Really? kinda defeats the purpose of it being a UDFi created a new topic, id like to move this UDF forward and update it myself, my current update to it is here:http://www.autoitscript.com/forum/index.php?showtopic=78378 https://johnscs.com Link to comment Share on other sites More sharing options...
HeidiR Posted August 28, 2008 Share Posted August 28, 2008 i thought my old _FTPxxx.au3 sucked. so i tryd using STD for it. but it failed. googled a bit and came across an vb site that used a windows dll, then i headed over to msdn to find out how to use em. this is the (unfinished) result. i am still writing alot of docs for it. since i want it included standardly. but i got sick of it and just decided to get some feedback first. [edit] uploaded a new version. for reference the old one got dl'ed 88 times. [/edit] [edit2] uploaded a new version. the other one wasnt even working. why didnt you guys say anything for reference the semi-old one got dl'ed 269 times. [/edit2] Does anyone know where I can find the latest ftp.au3 code? HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/ Link to comment Share on other sites More sharing options...
JohnMC Posted September 11, 2008 Share Posted September 11, 2008 Does anyone know where I can find the latest ftp.au3 code?http://www.autoitscript.com/forum/index.php?showtopic=78378recently updated, please provide feedback https://johnscs.com Link to comment Share on other sites More sharing options...
Nikkor Posted October 29, 2008 Share Posted October 29, 2008 Hello! Prompt please why functions _FTPFindFistFile (_FTPFileFindFist) _FTPFindNextFile (_FTPFileFindNext) do not return Creation Time Low, Creation Time Hight, Access Time Low, Access Time Hight, Last Write Low and Last Write Hight. Link to comment Share on other sites More sharing options...
Asaman83687 Posted October 30, 2008 Share Posted October 30, 2008 I've been reading this topic but does anyone know where's the download link or something similar for the latest update FTP.au3? Thanks! Link to comment Share on other sites More sharing options...
Brodway Posted October 31, 2008 Share Posted October 31, 2008 Hi I have download both files FTP.AU3 and FTP_EXAMPLE but I coud not make then work Anyone can help me to downlad some files from my ftp server everyday as soon my computer starts Thanks i thought my old _FTPxxx.au3 sucked. so i tryd using STD for it. but it failed. googled a bit and came across an vb site that used a windows dll, then i headed over to msdn to find out how to use em. this is the (unfinished) result. i am still writing alot of docs for it. since i want it included standardly. but i got sick of it and just decided to get some feedback first. [edit] uploaded a new version. for reference the old one got dl'ed 88 times. [/edit] [edit2] uploaded a new version. the other one wasnt even working. why didnt you guys say anything for reference the semi-old one got dl'ed 269 times. [/edit2] Link to comment Share on other sites More sharing options...
myspacee Posted December 20, 2008 Share Posted December 20, 2008 hello to all, start to read this post from start but i've already soma question : - is possible to list ftp directory ? if yes with file details (hour, filesize, etc) ? - need this script to build program that every hour check ftp directory and download only new generated files, is possible ? thank you for any reply, m. 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