JohnMC Posted October 22, 2008 Author Share Posted October 22, 2008 Hey I'm having some trouble with these functions and cant seem to get them to work in my script for some reason. I'm a bit of a noob as u can tell by my my post count, so I might just be doing something stupid. Also I've tried other variations of these functions none seem to work for me. Any help would be great. Here's the code pertaining to the ftp: #include <FTP.au3> ; yes this is the correct one just renamed it... $file = 'C:\folderpath\' & @ComputerName & '_' & @MON & '_' & @MDAY & '.html' ; this already exists $ftpfile = '/Files/' & @ComputerName & '_' & @MON & '_' & @MDAY & '.html' $server = 'ftp.drivehq.com' $username = 'MyUsername' $pass = 'MyPass' $handle = _FTPOpen('myftp') If @error Then MsgBox(0,'FTPOpen Error', @error) EndIf $ftpc = _FTPConnect($handle, $server, $username, $pass) If @error Then MsgBox(0,'FTPConnect Error', @error) EndIf ;the code works up till this point $ftpp = _FtpPutFile($handle, $file, $ftpfile) If @error Then MsgBox(0,'FTPPut Error', @error) ;this is where i get an error message EndIf _FTPClose($handle) Also if it makes any difference im using AutoIt v3.2.12.1 atm sorry for the delay in response, i dont know if you figgured it out by now.. i dont see any issue in your code... does the remote folder "Files" with a uppercase F already exist, im not sure if all the same case rules apply with unix ftp servers as with http have you tried using a simple example, without long file names, like _FtpPutFile($Hand, 'C:\ijustmadethis.txt', '/ijustmadethis.txt') 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...
tim08 Posted November 12, 2008 Share Posted November 12, 2008 Can someone explain the FTPPutFile line? I'm trying to send a picture to my FTP with the new .FTP.au3 file but no luck#include <file.au3> #include <.FTP.au3> $server = 'ftp.t35.com' $username = 'xxxx.t35.com' $pass = 'xxxx' $Open = _FTPOpen('MyFTP') $Conn = _FTPConnect($Open, $server, $username, $pass) $Ftpp = _FtpPutFile($Conn, 'C:\Windows\picture.jpg', 'what goes here?') $Ftpc = _FTPClose($Open) Link to comment Share on other sites More sharing options...
KaineIHC Posted November 22, 2008 Share Posted November 22, 2008 Can someone explain the FTPPutFile line? I'm trying to send a picture to my FTP with the new .FTP.au3 file but no luck #include <file.au3> #include <.FTP.au3> $server = 'ftp.t35.com' $username = 'xxxx.t35.com' $pass = 'xxxx' $Open = _FTPOpen('MyFTP') $Conn = _FTPConnect($Open, $server, $username, $pass) $Ftpp = _FtpPutFile($Conn, 'C:\Windows\picture.jpg', 'what goes here?') $Ftpc = _FTPClose($Open) You just need to put the destination in there, eg '\picture.jpg' will put it in the current folder on the server. BTW this is awesome, I've been trying to get the older version of FTP.au3 working without any luck. I got this version and ran the example and it worked straight away!! Thank you, Thank you, Thank you Link to comment Share on other sites More sharing options...
jvanegmond Posted December 5, 2008 Share Posted December 5, 2008 (edited) _FTPPutFile always errors out on me after a short duration.Here's the script:Local $opt_FTP_Server = "" Local $opt_FTP_Username = "" Local $opt_FTP_Password = "" $hFtp = _FTPOpen("FTPManadarX") If @error Then _Err("FTPOpen error: " & @error) _FTPConnect($hFtp, $opt_FTP_Server, $opt_FTP_Username, $opt_FTP_Password, 21, 1, 0x08000000) If @error Then _Err("FTPConnect error: " & @error) _FTPMakeDir($hFtp, "/public_html/test/") If @error Then _Err("FTPMakeDir error: " & @error) _FTPPutFile($hFtp,"C:\Documents and Settings\Jos\My Documents\AutoIt\Hooks.au3", "/public_html/test/hooks.au3") If @error Then _Err("FTPPutFile error: " & @error) _FTPClose($hFtp) If @error Then _Err("FTPClose error: " & @error) Func _Err($e) MsgBox(0,"Error!", $e) Exit EndFuncEdit: Fixed by connecting in passive mode. ( Can we possibly get a documentation update? ) Edited December 5, 2008 by Manadar github.com/jvanegmond 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 some questions : - see that is possible to list ftp directory ? with wich 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...
Zedna Posted December 20, 2008 Share Posted December 20, 2008 hello to all,start to read this post from start but i've already some questions :- see that is possible to list ftp directory ? with wich 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.Yes.Search for _FtpFileFindFirst(), _FtpFileFindNext() Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
myspacee Posted December 22, 2008 Share Posted December 22, 2008 (edited) download last source and modify test inside zip to understand usage, but i've some problem. Please explain for now only download from given ftp. My script: expandcollapse popup#include <.ftp.au3> #include <Array.au3>;only used for this test file to dispay the return value of the ftpfilefind function $server = 'ftp.symantec.com' $username = 'anonymous' $pass = 'pass' Local $RemoteDir = '/public/english_us_canada/antivirus_definitions/norton_antivirus/' Local $LocalDir = "C:\TempDir\" Local $Count = 0 ;$Hand will be a handle in the form of an array containing multiple handles and information, and is the only handle referenced $Hand = _FTPOpen('Doesnt Matter') ;In place of returning the "new" connect handle _FTPConnect like any other function will update the handle array already in use ;the return value will be as with any other function, 1 on success and 0 on failure $Ftpc = _FTPConnect($Hand, $server, $username, $pass) if @error then msgbox(0,"Error","Connect Error") Exit EndIf ;~ $Ftpp = _FtpPutFile($Hand, 'C:\WINDOWS\Notepad.exe', '/Example1.exe') ;~ $Ftpp = _FtpPutFile($Hand, 'C:\WINDOWS\Notepad.exe', '/Example2.exe') ;~ $Ftpm = _FTPMakeDir($Hand, 'ExampleFolder') ;~ $Ftpp = _FtpPutFile($Hand, 'C:\WINDOWS\Notepad.exe', '/ExampleFolder/Example3.exe') ;~ $Ftpg = _FTPGetFile($Hand, '/ExampleFolder/Example3.exe', @ScriptDir & '\Example3.exe') $Ftpff= _FTPFileFindFirst($Hand,"*") _ArrayDisplay($Ftpff) $Ftpffn= _FTPFileFindNext($Hand) _ArrayDisplay($Ftpffn) $Ftpffn= _FTPFileFindNext($Hand) _ArrayDisplay($Ftpffn) $Ftpffc = _FTPFileFindClose($Hand);Close filefind session (Only one _FTPFileFind can go on at a time so this must be used before using the _FTPGetFolderContents) _FTPGetFolderContents($Hand,"",$LocalDir,1);Needs trailing slash backslash $Ftpc = _FTPClose($Hand);Close ftp session for now i want to understand how download all content of REMOTEDIR '/public/english_us_canada/antivirus_definitions/norton_antivirus/' in local folder. Second step want to undestand how download new created files. (_FtpFileFindFirst(), _FtpFileFindNext()) Thank you any info, m. Edited December 22, 2008 by myspacee Link to comment Share on other sites More sharing options...
Jango Posted December 23, 2008 Share Posted December 23, 2008 Hello, Thank you for this update. Is this code work with SFTP server ? Link to comment Share on other sites More sharing options...
myspacee Posted December 23, 2008 Share Posted December 23, 2008 Sorry for ask again, anyone can post script example for download directory content from ftp server ? $server = 'ftp.symantec.com' $username = 'anonymous' $pass = 'pass' $RemoteDir = '/public/english_us_canada/antivirus_definitions/norton_antivirus/' thank you, m. Link to comment Share on other sites More sharing options...
myspacee Posted December 26, 2008 Share Posted December 26, 2008 Anyone can help me to use this with some example code ? m. Link to comment Share on other sites More sharing options...
JohnMC Posted January 10, 2009 Author Share Posted January 10, 2009 Sorry for ask again, anyone can post script example for download directory content from ftp server ? $server = 'ftp.symantec.com' $username = 'anonymous' $pass = 'pass' $RemoteDir = '/public/english_us_canada/antivirus_definitions/norton_antivirus/' thank you, m. #include <.ftp.au3> $server = 'ftp.symantec.com' $username = 'anonymous' $pass = 'pass' $RemoteDir = '/public/english_us_canada/antivirus_definitions/norton_antivirus/' $Hand = _FTPOpen('Doesnt Matter') _FTPConnect($Hand, $server, $username, $pass) _FTPGetFolderContents($Hand,$RemoteDir,@DesktopDir&"\ftp udf test\",1) Side Note: Im now working on this UDF again, i know its full of issues, and id like to sort them out so please let me know what you experience. Also the wininet UDF is well worth it, and i recomend it, my udf is a shortcut it almost everyway and will be usefull for a quick and dirty script, but might not be dependable for something larger. https://johnscs.com Link to comment Share on other sites More sharing options...
JohnMC Posted January 11, 2009 Author Share Posted January 11, 2009 Updated! See First Post https://johnscs.com Link to comment Share on other sites More sharing options...
TobiasO Posted February 2, 2009 Share Posted February 2, 2009 (edited) Hello all, I am glad this excist so i can cover up the password and also automate my upload while i make the file. But it doesn't work. I can connect but i cannot upload it with the _FtpPutFile ;i inserted the whole .ftp.au3 here $server = 'server' $username = 'user' $pass = 'pass' ;$Hand will be a handle in the form of an array containing multiple handles and information, and is the only handle referenced $Hand = _FTPOpen('Doesnt Matter') _FTPConnect($Hand, $server, $username, $pass) if @error then msgbox(0,"Error","Connect") _FtpPutFile($Hand, 'c:\selectie.txt', '/subdomains/sub/httpdocs/selectie.txt');Upload to sub directory with different file name if @error then msgbox(0,"Error","selectie.txt uploaden is niet gelukt") _FTPClose($Hand);Close ftp session i use AutoIt v3.3.0.0 and FTP UDF, Updated By JohnMC On Jan 10th 2009, TeamMC.cc And i use this on a Windows 2000 machine and also on a 2003 SBS, but on both it doesn't work. Anyobdy any idea? Cause i keep getting the Errorbox with ''selectie.txt uploaden is niet gelukt" (selectie.txt upload failed) Edited February 2, 2009 by TobiasO Link to comment Share on other sites More sharing options...
TobiasO Posted February 2, 2009 Share Posted February 2, 2009 Passive Mode fixed it Link to comment Share on other sites More sharing options...
Sticky Posted February 7, 2009 Share Posted February 7, 2009 (edited) When I attempt to download the latest file from your TeamMC site, it asks for a username and password? Edit: Nevermind, I attempted it without my downloading plugin and it worked. Edited February 7, 2009 by Sticky Link to comment Share on other sites More sharing options...
Yashied Posted February 10, 2009 Share Posted February 10, 2009 (edited) Well done, I used your UDF in their scripts. But why did you not use the functions InternetSetOption (for example, to set the timeout response from the FTP server). Without this script can not answer a long time. In my scripts I have used it. To set the timeout it will look like this:const $INTERNET_OPTION_RECEIVE_TIMEOUT = 6 const $TimeOut = 60 * 1000 ; ms local $WININET_HANDLE = DllOpen('wininet.dll') _InternetSetOptions($hInternet, $INTERNET_OPTION_RECEIVE_TIMEOUT, $TimeOut) func _InternetSetOptions($hInternet, $iOption, $iValue) local $tBuffer = DllStructCreate('int Value') DllStructSetData($tBuffer, 'Value', $iValue) DllCall($WININET_HANDLE, 'int', 'InternetSetOptionW', 'hwnd', $hInternet, 'int', $iOption, 'ptr', DllStructGetPtr($tBuffer), 'int', DllStructGetSize($tBuffer)) $tBuffer = 0 if (@error) or (_WinAPI_GetLastError() > 0) then return SetError(1, 0, 0) endif return SetError(0, 0, 1) endfunc; _InternetSetOptionsThe following list shows the options that can be set for $iOption:INTERNET_OPTION_CONTEXT_VALUEINTERNET_OPTION_CONNECT_TIMEOUTINTERNET_OPTION_CONNECT_RETRIESINTERNET_OPTION_CONNECT_BACKOFFINTERNET_OPTION_CONTROL_SEND_TIMEOUTINTERNET_OPTION_CONTROL_RECEIVE_TIMEOUTINTERNET_OPTION_DATA_SEND_TIMEOUTINTERNET_OPTION_DATA_RECEIVE_TIMEOUTINTERNET_OPTION_READ_BUFFER_SIZEINTERNET_OPTION_WRITE_BUFFER_SIZEINTERNET_OPTION_USERNAMEINTERNET_OPTION_PASSWORDINTERNET_OPTION_PROXYINTERNET_OPTION_USER_AGENTINTERNET_OPTION_RECEIVE_TIMEOUThttp://msdn.microsoft.com/en-us/library/ms918381.aspx Edited February 11, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
JohnMC Posted February 11, 2009 Author Share Posted February 11, 2009 (edited) Well done, I used your UDF in their scripts. But why did you not use the functions InternetSetOption (for example, to set the timeout response from the FTP server). Without this script can not answer a long time. In my scripts I have used it. To set the timeout it will look like this: const $INTERNET_OPTION_RECEIVE_TIMEOUT = 6 const $TimeOut = 60 * 1000 ; ms local $WININET_HANDLE = DllOpen('wininet.dll') _InternetSetOptions($hInternet, $INTERNET_OPTION_RECEIVE_TIMEOUT, $TimeOut) func _InternetSetOptions($hInternet, $iOption, $iValue) local $tBuffer = DllStructCreate('int Value') DllStructSetData($tBuffer, 'Value', $iValue) DllCall($WININET_HANDLE, 'int', 'InternetSetOptionW', 'hwnd', $hInternet, 'int', $iOption, 'ptr', DllStructGetPtr($tBuffer), 'int', DllStructGetSize($tBuffer)) $tBuffer = 0 if (@error) or (_WinAPI_GetLastError() > 0) then return SetError(1, 0, 0) endif return SetError(0, 0, 1) endfunc; _InternetSetOptions The following list shows the options that can be set for $iOption: INTERNET_OPTION_CONTEXT_VALUE INTERNET_OPTION_CONNECT_TIMEOUT INTERNET_OPTION_CONNECT_RETRIES INTERNET_OPTION_CONNECT_BACKOFF INTERNET_OPTION_CONTROL_SEND_TIMEOUT INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT INTERNET_OPTION_DATA_SEND_TIMEOUT INTERNET_OPTION_DATA_RECEIVE_TIMEOUT INTERNET_OPTION_READ_BUFFER_SIZE INTERNET_OPTION_WRITE_BUFFER_SIZE INTERNET_OPTION_USERNAME INTERNET_OPTION_PASSWORD INTERNET_OPTION_PROXY INTERNET_OPTION_USER_AGENT INTERNET_OPTION_RECEIVE_TIMEOUT http://msdn.microsoft.com/en-us/library/ms918381.aspx Great point, i should add this, but i help me out here... are there known issues with some options, most notably the timeout ones, i dont know if im getting this mixed up with a different project, but i remember people complaing about how it never worked right, thats why i never botherd also should i set these constants within this UDF, and are the values based on the posistion they have in the list on the msdn Edited February 11, 2009 by JohnMC https://johnscs.com Link to comment Share on other sites More sharing options...
IndyUK Posted March 2, 2009 Share Posted March 2, 2009 Hi, Does this UDF handle secure ftp sites? i.e sftp Thanks Link to comment Share on other sites More sharing options...
ghetek Posted March 4, 2009 Share Posted March 4, 2009 Does anyone have a working example of a file upload with progressbar? 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