Search the Community
Showing results for tags 'ftp'.
-
Hi all. Today I would like to introduce the beginning of the UDF. How to get started: http://winscp.net/eng/docs/library http://winscp.net/eng/docs/library_install Original readme_automation.txt: now I have only one function (standard FTP on standard port) to show the future possibilities: Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Const Enum _ $__eWSCP_SO_Protocol_Sftp, _ $__eWSCP_SO_Protocol_Scp, _ $__eWSCP_SO_Protocol_Ftp Const Enum _ $__eWSCP_TO_TransferMode_Binary, _ $__eWSCP_TO_TransferMode_Ascii, _ $__eWSCP_TO_TransferMode_Automatic Example_PutFile('YOUR FTP HOST NAME', 'YOUR USER NAME', 'YOUR PASSWORD') Func Example_PutFile($sHostName, $sUserName, $sPassword) Local $sFileFullPath = StringReplace(@ScriptFullPath, '\', '\\') Local $sFilesToPut = StringReplace(@ScriptDir & '\*.au3', '\', '\\') ; based on: ; http://winscp.net/eng/docs/library_com_wsh#vbscript Local $oSessionOptions = ObjCreate("WinSCP.SessionOptions"); With $oSessionOptions .Protocol = $__eWSCP_SO_Protocol_Ftp .HostName = $sHostName; .UserName = $sUserName; .Password = $sPassword; ; below not jet tested ; .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" EndWith Local $oSession = ObjCreate("WinSCP.Session"); With $oSession ; Connect: Open sesion with defined options .Open($oSessionOptions); ; Set TransferOptions Local $oTransferOptions = ObjCreate("WinSCP.TransferOptions") $oTransferOptions.TransferMode = $__eWSCP_TO_TransferMode_Binary ; Upload files: put @ScriptFullPath to the ROOT directory Local $oTransferResult = .PutFiles($sFilesToPut, '/'); ; Throw on any error $oTransferResult.Check ; Print results For $oTransfer In $oTransferResult.Transfers ConsoleWrite("Upload of " & $oTransfer.FileName & " succeeded" & @CRLF) Next ;' Disconnect, clean up .Dispose() EndWith ; CleanUp $oSession = '' $oSessionOptions = '' EndFunc ;==>Example_PutFile Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc EDIT: 2014-06-20 04:47 - script changed
-
Using the FTP FTPEx.au3 makes communicating with FTP a breeze. With great functions like _FTP_FileGet, _FTP_FilePut, and _FTP_DirPutContents, you can upload and download with ease. But what about the much needed ability to download a folder with a simple _FTP_DirGetContents function? Well I put together a function that will download a folder with ease... _FTP_DirGetContents Function: Func _FTP_DirGetContents($oConn, $opath, $olocal, $orec) If Not FileExists($olocal) Then DirCreate($olocal) If StringRight($opath, 1) <> "/" Then $opath &= "/" If $orec == 1 Then Local $ocurrent = _FTP_DirGetCurrent($oConn) _FTP_DirSetCurrent($oConn, $opath) Local $afolders = _FTP_ListToArray($oConn, 1) _FTP_DirSetCurrent($oConn, $ocurrent) For $o = 1 To $afolders[0] If $afolders[$o] == "." Or $afolders[$o] == ".." Then ContinueLoop If Not FileExists($olocal & "\" & $afolders[$o]) Then DirCreate($olocal & "\" & $afolders[$o]) _FTP_DirGetContents($oConn, $opath & $afolders[$o], $olocal & "\" & $afolders[$o], $orec) Next EndIf Local $hFTPFind Local $aFile = _FTP_FindFileFirst($oConn, $opath, $hFTPFind) While 1 _FTP_FileGet($oConn, $opath & $aFile[10], @ScriptDir & "\tmpdata\" & $aFile[10]) $aFile = _FTP_FindFileNext($hFTPFind) If @error Then ExitLoop WEnd _FTP_FindFileClose($hFTPFind) EndFunc Example Usage: #include <FTPEx.au3> If Not FileExist(@ScriptDir & "\ftptemp") Then DirCreate(@ScriptDir & "\ftptemp") $dir_local = @ScriptDir & "\ftptemp" $dir_remote = "/" Local $iOpen = _FTP_Open('MyFTP Control') Local $iConn = _FTP_Connect($iOpen, "YourFTPServer", "YourUsername", "YourPassword") _FTP_DirGetContents($iConn, $dir_remote, $dir_local, 1) _FTP_Close($iConn) _FTP_Close($iOpen) Function Call Explanation: _FTP_DirGetContents($oConn, $opath, $olocal, $orec) $oConn: session handle as returned by _FTP_Connect. $opath: The remote folder to download $olocal: The local folder to download to. $orec: set to 1 to download folder and subfolders. Set to 0 for non recursive. Enjoy
-
I have a smartphone and I use it to access my email. However, when composing an email on it I have a problem. My list of phone contacts on the phone is very different from my list of email contacts in my Thunderbird desktop app. I use my Gmail address book to store primarily phone contacts, and I use Thunderbird for my list of email contacts. I wanted a way to get my Thunderbird contact list onto my smartphone to be able to compose emails to addresses in that list. Here's my solution. I wrote a script to export my Thunderbird Personal Address Book to a csv file. It then reads that file and re-writes it with html wrappers around the data to make it into a nicely formatted web page. It then uploads the htm file to my website. On my smartphone, I created a shortcut to the file's URL and whenever I click it, I get the list displayed. Each contact shows name and email address along with a COPY button that will put the address into the clipboard. Then in my email client, I can easily paste that address into it. Alternatively, clicking on the actual email link will open a new message dialog in your email client with that address already entered. To use the app, all you need to do is use Thunderbird and have a webserver available. You'll need to download the FTPEX.AU3 file from this website and make a few changes to some constants around line 17 for FTP login info, etc. pab2ftp.au3
-
- address book
-
(and 2 more)
Tagged with:
-
The following function successfully connects to and uploads a local text file named user.dat I have checked the data being written to the text file when it is created locally using a MsgBox and it appears exactly how it should be written to the file. If I comment out the FileDelete and go and open the file locally it is as expected. However when I download the file from the FTP server and open it up the text that should be at the end of the file is missing. With each subsequent run more characters are missing. I added the Sleep(5000) in case the function was closing the FTP connection too quickly before the file could be fully written but it makes no difference. The user.dat file is (should be) approximately 100 bytes so it is tiny. Any idea why this is happening? Func UpdateUserData() ; Upload the modified user.dat file Local $hOpen = _FTP_Open("myftp") Local $hConn = _FTP_Connect($hOpen, "my.ftp.server", "user", "pass", 1, 0, 1, 2) If @error Then MsgBox(16, "Error", "Connection failed" & @CRLF & @CRLF & "Please contact support") _FTP_Close($hConn) _FTP_Close($hOpen) Exit EndIf _FTP_FilePut($hConn, @TempDir & "\user.dat", "user.dat") ; Upload the new user.dat file Sleep(5000) If @error <> 0 Then MsgBox(16, "Error", "Couldn't transmit data" & @CRLF & @CRLF & "Please contact support") _FTP_Close($hConn) _FTP_Close($hOpen) Exit EndIf _FTP_Close($hConn) _FTP_Close($hOpen) FileDelete(@TempDir & "\user.dat") EndFunc
-
Hello, This is my first post. So I’ve worked on a script for a while and I’m planning to publish it but the problem is that it connects to an FTP server at some point, and as you probably know FTP credentials are easily captured by a MITM attack or Wireshark (not sure if Wireshark does). So I thought if i can detect data capturing in the user’s network the script would stop. Any idea?. If there’s another workaround I’m happy to hear it.
-
Hello, I am attempting to pull a list of the directory structure from a public FTP where no username or password is required i.e: ftp://ftp.adobe.com/pub/adobe/ Now I have looked all over the place and have failed find anything to accomplish, and if I found some, and the documentation is rather bleak for example; it does show something I am looking for, but there is no ftp.au3, and the usage and examples of what i want to do seems to elude me on this and it may not even apply to what I am trying to accomplish? I want to avoid using things with Internet explorer , and I have done some google searches. However nothing seems to help the documentation surrounding : _FTP_DirGetCurrent references _FTP_Connect , and then references _FTP_Open , and regardless what I try I cannot get it to pull a list of directorys of files as a list. Any help is appreciated
-
Hi, Ones(some times twice) a month I get an e-mail with zip file, which has price updates from a supplier. I have to upload the file to an FTP to get it processed. When uploading the file, it will get "timestamped" with the time and date at which time the file was uploaded. Normally this is fine, because I mostly upload the file the same day. Sometimes it may take 1 or 2 days before I can upload the file. For historical purpose, I would like to have the file timestamped with the original date. I have tried using: _FTP_Command ( $hFTPSession, "MFCT YYYYMMDDHHMMSS path") however this command does not work or change the timestamp as I expected. Does anyone now a way how I can change the timestamp of a FTP-file?
-
As for now I was using such kind of snippet: Local $aFTP_FileList = _FTP_ListToArray($hFTPSession, 2) For $iFTPFileSize_idx = 1 To $aFTP_FileList[0] ConsoleWrite('Pobieram informacje o pliku:' & $aFTP_FileList[$iFTPFileSize_idx] ) $iWielkoscPliku = _FTP_FileGetSize($hFTPSession, $aFTP_FileList[$iFTPFileSize_idx]) ConsoleWrite($iFTPFileSize_idx & ' : ' & $aFTP_FileList[$iFTPFileSize_idx] & ' rozmiar=' & $iWielkoscPliku) Sleep(200) Next But from some time my clients start buying cheap WD MyCloud NAS, and my problems starts. On all others NAS there is no problem (Seagate BlackArmour, QNAP, SYNOLOGY .... ). When on list there is for example 20 files then first two of them are very fast checked and reported they FileSize. After 2 files there is about 20 sec stop....... and next two files are checked with no errors but FileSize == 0 again there is about 20 sec stop....... and next two files are checked with no errors but FileSize == 0 again there is about 20 sec stop....... and next two files are checked with no errors but FileSize == 0 again there is about 20 sec stop....... and next two files are checked with no errors but FileSize == 0 again there is about 20 sec stop....... and next two files are checked with no errors but FileSize == 0 ....... In time when I process investigation I checked how : _FTP_ListToArray2D and _FTP_ListToArrayEx works and I was shocked that they works super fast. Here are the questions: Q1: Why does the problem occur only on WD MyCloud NAS? Q2: What is the significant difference that makes using _FTP_ListToArray2D and _FTP_ListToArrayEx to retrieve file sizes is still fast? Q3: Why _FTP_FileGetSize() not reporting @errors but returned FileSize = 0 Regards, mLipok
-
Hello, i need help in deleting files from a server. The function "_FTP_DirDelete" only deletes a directory when its empty. I need to delete a non empty directory. I also can not delete the files in this directory first, because the files are PAG and DIR files in a .DAV directory and FTPEx.au3 doesnt like a directory starting with a ".". Any ideas? Thx, Sally
-
Hi, I have written a small script to read a file from an FTP server and check its contents. This can be re-run by the press of a button, however, if the file is deleted from the ftp server between runs (with the .exe still live), the file is still "read" and written locally, which then passes the check. If I run it initially without the file, it correctly fails and pops up my error message, but if the file is then added, it then seemingly gets cached (or similar) so that the app then always reports a success. The below code snippet is just the function run when the "test" button is pressed. It includes a load of debug message boxes, and from that I think I've gathered a few (possibly) interesting/relevant things: $Open and $Conn are 8 byte values, which increments (not by 1) when the FTP connection is not closed, but if the connection is closed, they stick at the value (presumably windows can re-use that session id if it's been closed e.g: 1st run (file not present) $Open -> 0x00CC0004 $Conn -> 0x00CC0008 2nd run (file not present) $Open -> 0x00CC0010 $Conn -> 0x00CC0014 3rd run (file now present) $Open -> 0x00CC001C $Conn -> 0x00CC0020 4th run (file still present) $Open -> 0x00CC001C $Conn -> 0x00CC0020 $Ftp = _FTP_FileGet.... returns a 1 when file not present (in a run after it was present) and "test_transfer.txt" does get created and does contain the correct string This is the key bit I dont understand, I dont know how/where it is getting the data to write this file when it literally no longer exists on the target FTP server... resetting every variable used in the function each time it's run does work (in that they become 0), but it doesn't affect the putcome I had thought perhaps some key values were being stored in the variables, but this doesn't seem to be the case Is there any concept of clearing a cache when closing an ftp session? Or deleting any unknown temporary files windows might make? Thanks all Func Transfer() Local $connected = 0 $Ftpp = 0 ;Trying to reset these every time function is called $file = 0 $Open = 0 $Conn = 0 $Ftpc = 0 ;Make a new "connecting..." window so that the user has feedback that a transfer is attempting to take place ;Otherwise it just runs in the background and there's no indication its doing anything $connection_window = GUICreate ("Ethernet Switch Test" , 300 , 160 , -1 , -1 , -1 , -1 , 0) GUISetBkColor(0xFFFFFF) GUISetFont(10 * _GDIPlus_GraphicsGetDPIRatio()[0], 400, Default, "Sans Serif") $connecting_label = GUICtrlCreateLabel("Connecting to board...", 0, 25, 300, -1, $SS_Center, "") GUISetState(@SW_SHOW, $connection_window) Sleep(100) ;Connect ;MsgBox(0, "DEBUG", "1" & $Conn) While $connected = 0 $Open = _FTP_Open($count) ;MsgBox(0, "DEBUG", "open " & $Open) $Conn = _FTP_Connect($Open, $server, $username, $password) ;MsgBox(0, "DEBUG", "2" & $Conn) If $Conn = 0 then Local $retry = Msgbox(65, 'FTP Transfer', 'Connection failed' & @CRLF & "Retry?") If $retry = 2 Then MsgBox(0, "FTP Transfer", "Operation aborted") GUISetState(@SW_HIDE, $connection_window) Return EndIf Else $connected_label = GUICtrlCreateLabel("Connected!", 0, 45, 300, -1, $SS_Center, "") $connected = 1 MsgBox(0, "DEBUG", "3" & $connected) Sleep(100) endIf WEnd $transfering_label = GUICtrlCreateLabel("Reading file....", 0, 45, 300, -1, $SS_Center, "") ;Read file from server ;MsgBox(0, "DEBUG", "5" & $Ftpp) ;MsgBox(0, "DEBUG", "flie " & $file) $Ftpp = _FTP_FileGet($Conn, 'test/test.txt', 'test_transfer.txt') ;MsgBox(0, "DEBUG", "6" & $Ftpp) If ($Ftpp) then $transfered_label = GUICtrlCreateLabel("Transfered, checking...", 0, 65, 300, -1, $SS_Center, "") ;MsgBox(0, "DEBUG", "flie " & $file) $file = FileRead("test_transfer.txt") ;MsgBox(0, "DEBUG", "flie " & $file) If Not StringInStr($file, 'this is a test string 12345') Then MsgBox(0, "File check", "Received file incorrect, test failed!") GUISetState(@SW_HIDE, $connection_window) Return Else $tested_label = GUICtrlCreateLabel("Tested and Passed!", 0, 85, 300, -1, $SS_Center, "") $Ftpc = _FTP_Close($Open) ;MsgBox(0, "DEBUG", "close" & $Ftpc) ;$count = $count+1 $ok_button = GUICtrlCreateButton("OK", 125, 105, 50, -1) While 1 Local $pressed = GUIGetMsg() If ($pressed = $ok_button) Then FileDelete("test_transfer.txt") GUISetState(@SW_HIDE, $connection_window) ;$connection_window = 0 Return EndIf WEnd EndIf Else MsgBox(0, "Transfer", "Could not read file " & @error) GUISetState(@SW_HIDE, $connection_window) Return EndIf EndFunc
-
Hi, I'm trying to download a file from a secure site that doesn't allow ftp. I've been trying to use FTPS but I can't find anything about FTPS (or FTP over SSL) except one reference that was a few years ago. So I'm wondering if things have changed. I've trawled through WinHttp and FF but can't find anything. If anyone has some good ideas I'd love to hear from you. here is one example of what I tried, and it seemed to work at first but then there was no response at the end:( #include <string.au3> #include <inet.au3> #include <guiconstants.au3> #include <winhttp.au3> Dim $hw_connect, $hw_open, $h_openRequest, $LocalIP, $M $LocalIP = "https://www.example.org" $hw_open = _WinHttpOpen() $hw_connect = _WinHttpConnect($hw_open, $LocalIP) $h_openRequest = _WinHttpOpenRequest($hw_connect, "GET", "programname.exe") MsgBox(0,"",$hw_connect&@error) $M = _WinHttpSetCredentials($h_openRequest, $WINHTTP_AUTH_TARGET_SERVER, $WINHTTP_AUTH_SCHEME_BASIC, "username", "password") MsgBox(0,"",$M) $M= _WinHttpSendRequest($h_openRequest) MsgBox(0,"",$M) $M= _WinHttpReceiveResponse($h_openRequest) MsgBox(0,"",$M& " " &@error)
-
I have used this code for a long time, but for a week or 2 it stopped working? Connection is ok, the put create the file on server if I delete it on the FTP server, but the file is empty and after 30 secondees the function return 0 I have tested on 2 machines, Filezilla FTP client have no issue to the server. Firewall is disabled under test. If $writeFTP = True Then $Open=_FTPOpen('MyFTP Control') $Conn=_FTPConnect($Open, $destinationServer, $destinationUsername, $destinationPass) MsgBox(0,"start","start") $Ftpp=_FtpPutFile($Conn, $filePath&$name&".json", "httpdocs/p_calender/" & $name & ".json") MsgBox(0,"return","return"&$Ftpp) Exit $Ftpc=_FTPClose($Open) EndIf From the Lib: 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 ;==> _FTPPutFile()
-
In documentation for: #include <FTPEx.au3> _FTP_Connect ( $hInternetSession, $sServerName, $sUsername, $sPassword [, $iPassive = 0 [, $iServerPort = 0 [, $iService = $INTERNET_SERVICE_FTP [, $iFlags = 0 [, $fuContext = 0]]]]] ) There are two parameters for Passive: My question is: What is a difference beetwen using : $iPassive = 1 and $iFlags = $INTERNET_FLAG_PASSIVE Regards, mLipok
-
Screenshot program that can upload/FTP to website/storage with hotkey. Features GUI to display programmable keys. Set the hotkeys with this function to use, and display hotkeys. ; hotkey_set() Parameters: ; ----------------------------------------------------------- ; $aHotkey - The array hotkeys are stored in. This function sets the values of this array[hotkey_id][$hotkey_data] ; $dHotkey_id - The enum for this hotkey index ; $sHotkey_description - The label displayed to the user to represent function of hotkey ; $sHotkey_name - The hotkey it'self. Whatever name string you want to give the key ; $dHotkey_key - The _IsPressed keycode ; Keycodes AT: https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm ; $dHotkey_shift - Shift flag 0 or 1 Default off ; $dHotkey_ctrl - Ctrl flag 0 or 1 Default off ; $dHotkey_alt - Alt flag 0 or 1 Default off Func hotkey_set(ByRef $aHotkey, $dHotkey_id, $sHotkey_description, $sHotkey_name, $dHotkey_key, $dHotkey_shift = 0, $dHotkey_ctrl = 0, $dHotkey_alt = 0) $aHotkey[$dHotkey_id][$eHotkey_data_key_description] = $sHotkey_description $aHotkey[$dHotkey_id][$eHotkey_data_key_name] = $sHotkey_name $aHotkey[$dHotkey_id][$eHotkey_data_key] = $dHotkey_key $aHotkey[$dHotkey_id][$eHotkey_data_shift] = $dHotkey_shift $aHotkey[$dHotkey_id][$eHotkey_data_ctrl] = $dHotkey_ctrl $aHotkey[$dHotkey_id][$eHotkey_data_alt] = $dHotkey_alt EndFunc ;==>hotkey_set ; You can set your hotkeys here ; Please visit the hotkey_set() function for parameter information hotkey_set($aHotkey, $eHotkey_screenshot_ftp, "Selected Window to FTP", "F12", "7B", 0, 1, 0); F12 hotkey_set($aHotkey, $eHotkey_screenshot_disk, "Selected Window to Disk", "S", "53", 1, 1, 1); S hotkey_set($aHotkey, $eHotkey_clipboard_send, "Send Clipboard keystrokes", "F10", "79", 1, 1, 1); F10 Configure settings dialog: Screenshot Filename and Screenshot Counter, are used to create simple unique filenames that can cycle. Copy URL to clipboard option. - For linking your screenshots. The screenshot file type is for local copy only. App always uses .JPG for FTP right now, but I could add FTP screenshot file type specification. Any suggestions? Did I break anything, what did I miss? Package uses TTS.au3 by Beege: FTP_Screen.zip File includes: - FTP_Screen.au3 - FTPScreen.ico - TTS.au3 - by Beege
-
Hi, I'm looking to create a script which will download all *.txt files from a remote FTP server. Once downloaded, delete all *.txt files. Can this be achieved using AutoIt ?
-
Hi folks, I'm using the udf #include <FTPEx.au3> to "download" some files from our zOS (MVS) system via autoit FTP with _FTP_FileGet. The FileGet works, but the codepage is wrong. Special German chars like öäüß are not transfered correctly. Any idea how to set the codepage? Swichting between binary or ascii doesn't solve the problem. Using the ftp command in a cmd.exe window it works like this : quote site sbd=(IBM-273,iso8859-1) Thanks Mega
-
Hi, how to get full error reporting if FTP failed? tried _WinAPI_GetLastErrorMessage() func but That didn't help at all. the information was returned by _WinAPI_GetLastErrorMessage() can't help me! _FTP_Open, return Success: a handle, Failure: 0 and sets the @error flag to non-zero _FTP_Connect, return Success: an handle to connected session. Failure: 0 and sets the @error flag to non-zero. _FTP_DirCreate, return Success: 1. Failure: 0. _FTP_FilePut, return Success: 1. Failure: 0 and sets the @error flag to non-zero. Any help would be much appreciated
-
Hi All, I need some help, I am writing a script that FTPs some files and then outputs the results, but I am unable to figure out how to output the file name on line 58. Here is the code (modified to exclude personal information): #include <FTPEx.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Inet.au3> #include <Debug.au3> #include <File.au3> #include <Array.au3> Local $Server = 'ftp.com' Local $Username = 'user' Local $Password = 'password' Local $LocalFolder = 'C:\Folder' Local $RemoteFolder = '/users/user1' Local $SMTPServer = "Exchange.domain.com" Local $FromName = "FTP" Local $FromAddress = "email@address.com" Local $ToAddress = " email@address.com " Local $Subject = "FTP Transfer Failed, please check server" Local $Subject1 = "FTP Connection Failed, please check server" Local $Body[2] $Body[0] = "Line 1" $Body[1] = "Line 2" Local $Body1[2] $Body1[0] = "Line 1" $Body1[1] = "Line 2" $LogFolder = "\\COMP\LOGS" _DebugSetup ("Debug", True) FileMove ("\\COMP\Test\*.txt", "\\COMP\FTP") Local $FolderContents = _FileListToArray("\\COMP\FTP") Local $LogFile = "\FilesToSend_" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & ".log" _FileCreate($LogFolder & $LogFile) _FileWriteFromArray($LogFolder & $LogFile, $FolderContents) If FileExists ( "\\COMP\FTP" ) Then Local $Open = _FTP_Open('FTP') Local $CallBack = _FTP_SetStatusCallback($Open, 'FTPStatusCallbackHandler') Local $Connect = _FTP_Connect($Open, $Server, $Username, $Password, 0, $INTERNET_DEFAULT_FTP_PORT, $INTERNET_SERVICE_FTP, 0, $CallBack) If $Connect <> 0 Then Local $Transfer = _FTP_DirPutContents($Connect, $LocalFolder, $RemoteFolder, 0) _FTP_Close($Connect) _FTP_Close($Open) Else _INetSmtpMail($SMTPServer, $FromName, $FromAddress, $ToAddress, $Subject1, $Body, "EHLO" & @ComputerName, -1) EndIf If $Transfer = 1 Then FileMove ( "\\COMP\FTP\*.txt", "\\COMP\Test\SENT") Else _INetSmtpMail($SMTPServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body1, "EHLO" & @ComputerName, -1) EndIf EndIf Func FTPStatusCallbackHandler($hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength) #forceref $hInternet, $iContext If $iInternetStatus = $INTERNET_STATUS_REQUEST_SENT or $iInternetStatus = $INTERNET_STATUS_RESPONSE_RECEIVED Then Local $iBytesRead Local $tStatus = DllStructCreate('dword') _WinAPI_ReadProcessMemory(_WinAPI_GetCurrentProcess(), $pStatusInformation, $tStatus, $iStatusInformationLength, $iBytesRead) _DebugOut(_FTP_DecodeInternetStatus($iInternetStatus) & ' | Size = ' & DllStructGetData($tStatus, 1) & ' Bytes Bytes read = ' & $iBytesRead) Else _DebugOut(_FTP_DecodeInternetStatus($iInternetStatus)) EndIf EndFunc I would like the output on line 58 to include a file name, at the moment it only displays the size of the file and Bytes read. Here is what is currently outputted: Handle created Resolving name ... Name resolved Connecting to server ... Connected to server Receiving response ... Response received | Size = 58 Bytes Bytes read = 4 Sending request ... Request sent | Size = 13 Bytes Bytes read = 4 Receiving response ... Response received | Size = 20 Bytes Bytes read = 4 Sending request ... Request sent | Size = 19 Bytes Bytes read = 4 Receiving response ... Response received | Size = 20 Bytes Bytes read = 4 Handle created Handle created Handle created Handle created Handle created Closing connection ... Connection closed Handle closing ... Any help would be greatly appreciated! Thanks.
-
Hi All, I am trying to write a script that FTPs multiple files to the same destination using the same FTP session. The script takes the source files, places them on the FTP server, the files should be FTP'd and then moved into the SENT folder in the original location. I seem to have got everything working except when i try to FTP multiple files, if i put a specific file name under $LocalFile & $RemoteFile under FTP_FilePut then the script works, can anyone tell me where I am going wrong please? I've visited other forums and input an array for the $LocalFile which seems to work, as if i put an ArrayDisplay in it does show me all the files in the folder. I have tried to enter a path, "". '' and "*.*" for $RemoteFile but nothing seems to work: #include <FTPEx.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Inet.au3> #include <Debug.au3> #include <File.au3> #include <Array.au3> Local $Server = 'ftp.com' Local $Username = 'user' Local $Password = 'password' Local $LocalFile = 'C:\FTP\doc.txt' Local $RemoteFile = '*.*' Local $FilePath = 'C:\FTP' FileMove ("\\COMP\Source\*.txt", "\\COMP\FTP") If FileExists ( "\\COMP\FTP" ) Then Local $FileList = _FileListToArray($FilePath, "*", 1) Local $Open = _FTP_Open('FTP Test') Local $Connect = _FTP_Connect($Open, $Server, $Username, $Password) If $Connect <> 0 Then For $i = 1 to $FileList[0] - 1 Local $Transfer = _FTP_FilePut($Connect, $FileList[$i], "" ,0 ,0) <------------- I think the problem is with the $RemoteFile part Next _FTP_Close($Connect) _FTP_Close($Open) FileMove ( "\\COMP\FTP\*.txt", "\\COMP\Source\SENT") EndIf EndIf
-
I have inputted correct code for FTP but I get nothing on my server. #include <FTPEx.au3> Local $sServer = 'ftpserver' Local $sUsername = 'username' Local $sPass = 'pass' Local $hOpen = _FTP_Open('MyFTP Control') Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass) _FTP_FilePut ( $hConn, @ScriptDir & '\FTP.au3' , '/FTP.au3' ,0 ,0 )How can it be wrong? My server is can use port default 0(20) and can use Filezilla to upload on that. I have researched on this forum but still cannot fix this. Thank you for your attention.
-
I have started using this UDF SFTPEx.au3 to download a bunch of files from a remote server to local. First, Great job with the UDF and this really works! awesome work Lupo73... Second, there is no timestamps on the listed files when I use the function _SFTP_ListToArrayEx. Screenshots attached Third, Is the _SFTP_ProgressDownload function still Work in Progress? I am using the version 1.0 beta 9 using _ArrayDisplay function using Filezilla Can the developers please help me with these questions?
-
I'm using ftp functions but the modification time always have 0 seconds. Is it how it should work? I checked in FileZilla and it returns seconds.
-
- ftp
- modification
-
(and 1 more)
Tagged with:
-
Hi All, Here is a little GUI I built a while back to learn how to use INI files to store information ( variables ) between opening and closing certain programs. I just recently pulled it back out and cleaned it up and debugged it, if you find any bugs please kill them. The FTP connection part was just so it would have purpose... To cut down on clutter there are no labels, hover mouse over to see what things are. cya, Bill
-
Hi, i have problem to get all files from server in list, it say in help file that u can get data from current session but it wont work #RequireAdmin #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIListBox.au3> #include <GUIListView.au3> #include <FTPEx.au3> #include <Array.au3> #Region ### START Koda GUI section ### $GUI = GUICreate("FTP tool", 754, 613, 691, 157) GUICtrlCreateLabel("Host", 16, 16, 26, 17) GUICtrlCreateLabel("Port", 192, 16, 23, 17) GUICtrlCreateLabel("Username", 16, 56, 52, 17) GUICtrlCreateLabel("Password", 16, 88, 50, 17) GUICtrlCreateLabel("Status : ", 8, 152, 43, 17) $status = GUICtrlCreateLabel("Not connected", 52, 152, 221, 17) $host = GUICtrlCreateInput("", 48, 12, 121, 21) $port = GUICtrlCreateCombo("", 224, 12, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "21|80") $username = GUICtrlCreateInput("", 79, 52, 121, 21) $password = GUICtrlCreateInput("", 79, 81, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $connectBtn = GUICtrlCreateButton("CONNECT", 56, 192, 75, 25) $disconnectBtn = GUICtrlCreateButton("DISCONNECT", 143, 192, 107, 25) $List = GUICtrlCreateList("", 16, 240, 721, 340, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If GUICtrlRead($status) = 'Not connected' Then GUICtrlSetState($disconnectBtn, $GUI_DISABLE) ; disable disconnect button if not connected GUICtrlSetData($port, '21') ; default port Global $status, $host, $port, $username, $password, $FTPopen, $FTPConnect, $List While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $connectBtn _connectFTP() Case $disconnectBtn _disconnectFTP() EndSwitch WEnd ; connection to FTP server Func _connectFTP() Local $_host = GUICtrlRead($host) ; host name Local $_username = GUICtrlRead($username) ; username Local $_password = GUICtrlRead($password) ; password Local $_port = GUICtrlRead($port) ; port Local $FTPopen = _FTP_Open('FTP connection test') ; name of connection Local $FTPConnect = _FTP_Connect($FTPopen, $_host, $_username, $_password, '', $_port) ; connect ; try to connect to server If Not @error Then ; if not error GUICtrlSetData($status, 'Connected') ; set status to connected GUICtrlSetState($connectBtn, $GUI_DISABLE) ; disable connect button GUICtrlSetState($disconnectBtn, $GUI_ENABLE) ; enable disconnect button _listData() Else MsgBox(48, 'FTP connection error', "Can't connect to server, error = " & @error) ; if there is connection error EndIf EndFunc ; disconnect from FTP server Func _disconnectFTP() _FTP_Close($FTPopen) _FTP_Close($FTPConnect) GUICtrlSetState($disconnectBtn, $GUI_DISABLE) GUICtrlSetState($connectBtn, $GUI_ENABLE) GUICtrlSetData($status, 'Not connected') _GUICtrlListBox_ResetContent($List) EndFunc ; list all files on FTP server Func _listData() ; get current dir on server $FTPdirData = _FTP_DirGetCurrent($FTPopen) ; Add files in list box _GUICtrlListBox_BeginUpdate($List) _GUICtrlListBox_ResetContent($List) _GUICtrlListBox_Dir($List, "", $FTPdirData, False) _GUICtrlListBox_EndUpdate($List) EndFunc