Jump to content

Search the Community

Showing results for tags 'ftp'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • Forum
  • AutoIt


  • Community Calendar

Found 30 results

  1. 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
  2. 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()
  3. 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
  4. 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
  5. FTP_Screen

    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
  6. 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 ?
  7. 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
  8. 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
  9. 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.
  10. 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
  11. FTP Fileput

    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.
  12. 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?
  13. 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.
  14. 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
  15. 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
  16. Hi, i have problem with connection on ftp with example script i get message all time "ERROR = -1", but in filezilla or other ftp client i connect normally with same data ? And what this _FTP_Open('') means, i can write what i want in ? like this is my connection name or something from server ? thanks in advance #include <FTPEx.au3> #include <MsgBoxConstants.au3> Local $sServer = '*********' Local $sUsername = '**********' Local $sPass = '*********' Local $hOpen = _FTP_Open('MyFTP Control') Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass) If @error Then MsgBox($MB_SYSTEMMODAL, 'FTP Connection : ', 'ERROR = ' & @error) Else MsgBox($MB_SYSTEMMODAL, 'FTP Connection : ', 'Connected') EndIf Local $iFtpc = _FTP_Close($hConn) Local $iFtpo = _FTP_Close($hOpen) SOLVED missed to add #RequireAdmin
  17. Hey autoIT community! I am having a bit of trouble, I am trying to communicate with my FTP server to upload a file, I have tried this script, but it won't work: #include <FTPEx.au3> Func FTP() $server = 'ftp.myftphost.com' $username = 'MyFtpUsername' $pass = 'MyFtpPassword' $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, $username, $pass) $Ftpp = _FTP_FilePut($Conn, 'C:\Users\MyUserName\Desktop\test.au3', '/htdocs') $Ftpc = _FTP_Close($Open) Exit EndFunc I don't understand why it won't work, all of the ftp credentials are correct... If someone could help me it would be real nice. Thanks
  18. So I have a project that has been sitting for a long time, and I think I just finally found the answer to the problem. FTPEx.au3 but I am having some minor issues and would want to make sure I get some expert advice since this is going to be important that it works right if I implement it. Goal: To have several computers in the field update a map file automatically every once in a while. The map file is between 500MB and 1GB I have basic FTP working so far to transfer a single file: #Include <FTPEx.au3> #Include <Array.au3> $vFTPSes = _FTP_Open("PSFTP") ;MsgBox(0, "", @Error) $vFTPSes2 = _FTP_Connect($vFTPSes, "my server", "my user", "my pw") ;MsgBox(0, "", @Error) _FTP_FileGet($vFTPSes2, "/Tiburon FTP Update/Maps/test.txt", "C:\Users\frpatrmo\desktop\Get Map Update\Maps\test.txt", "True") ;MsgBox(0, "", @Error) _FTP_Close($vFTPSes2) My first issue is this, the "file" is actually a directory of MANY files and I cant find anywhere in the help files a way to transfer an entire directory instead of a file. If that can be done, thats pretty much my largest hurdle right now. Instead I bet that I will need to use a loop and an array of files. I looked at the filelist to array functions like _FTP_ListToArray but it lists every file at the root of the FTP server, I need it to drill down to the specific directory where the files I need are located. Other than that I assume that in a script that the file transfer will finish before the next command is run, this way I can ensure I do not put an incomplete download file into the application directory. My logic tells me to download the file to @TempDir and when/if it completes the entire download to then have AutoIT move/copy the directory to the program location to be used. This way if the download never finishes it never gets moved/copied. After I get this initial trouble figured out, I then need to find the best way to make this run about 1 time a week silently and then not run again for another week on a multi user computer environment. As always appreciate the help. Edit: Ok found _FTP_DirSetCurrent() lets me set my desired folder as the current Dir and then the _FTP_ListToArray() will show me the correct files. Still a long way to go however, since its a mix of folders and files and I have no idea how to loop it to get everything transferred.
  19. 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
  20. When I upgraded from version to the latest I have the included functions _FTP_ProgressDownload and _FTP_ProgressUpload always showing a separate progress window, and not using the progress bar in the main gui. This happens also with the example code from the Help : #include <FTPEx.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <ProgressConstants.au3> Global $g_sRemoteFile = "/pub/software/databases/rt/SRPMS/ucs-local-modperl-2.0.3-1.src.rpm" Global $g_sLocalFile = @TempDir & "\temp.tmp" FileDelete($g_sLocalFile) Local $sServer = 'ftp.csx.cam.ac.uk' Local $sUsername = '' Local $sPass = '' Local $hInternetSession = _FTP_Open('MyFTP Control') ; passive allows most protected FTPs to answer Local $hFTPSession = _FTP_Connect($hInternetSession, $sServer, $sUsername, $sPass, 1) Global $g_idProgressBarCtrl, $g_idBtn_Cancel Example() _FTP_Close($hInternetSession) Func Example() ; create GUI GUICreate("My GUI download Progressbar", 220, 100, 100, 200) GUICtrlCreateLabel($g_sRemoteFile, 10, 10) $g_idProgressBarCtrl = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH) GUICtrlSetColor(-1, 32250); not working with Windows XP Style $g_idBtn_Cancel = GUICtrlCreateButton("Cancel", 75, 70, 70, 20) GUISetState(@SW_SHOW) Local $sFunctionToCall = "_UpdateGUIProgressBar" _FTP_ProgressDownload($hFTPSession, $g_sLocalFile, $g_sRemoteFile, $sFunctionToCall) EndFunc ;==>Example Func _UpdateGUIProgressBar($iPercent) GUICtrlSetData($g_idProgressBarCtrl, $iPercent) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit -1 ; _FTP_DownloadProgress Aborts with -1, so you can exit your app afterwards Case $g_idBtn_Cancel Exit -2 ; Just Cancel, without special Return value EndSwitch Return 1 ; Otherwise continue Download EndFunc ;==>_UpdateGUIProgressBar And #include <FTPEx.au3> is the latest (June 1 2014) In my system the result is like this https://www.dropbox.com/s/kg9q7c4rzhmzrjk/errorFTPprogress.JPG?dl=0 Why ?
  21. WinSCP - UDF

    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
  22. Hi , I feel like a newbie this friday afternoon. Basically iam trying to connect a ftp enter a folder , go back up and enter a new one. I did never found out how to do the up one level . or just back to root will do for my script i did try all the combo i know for that like _FTP_Command($Conn,"cwd ..") _FTP_Command($Conn,"cwd ::") _FTP_Command($Conn,"cwd ../") _FTP_Command($Conn,"cwd /") So being lazy on this friday , i just did 2 full connection process in 2 function . to my big surprise still stuck with file list from my first function into my second. So i did rename all my variable to new name in 2 function , still the same problem . I guess some call do not get clean close . from bug to typo any one got a idea where i screw up . Here a ugly coding test , but i just cannot get those 2 function work back to back , individually they work perfect . Obvious i can do ftp via batch/PS/vbs , but i rather have this work in 1 pass Anyone got a idea what wrong here ? #include <FTPEx.au3> #include <Array.au3> ftpgetfile() sleep(1000) ftpgetfile2() Func ftpgetfile() Local $server = 'ftp.test.local' Local $username = 'myuser' Local $pass = 'mypass' Local $Open = _FTP_Open('MyFTP Control') Local $Conn = _FTP_Connect($Open, $server, $username, $pass,1) _FTP_Command($Conn,"cwd /folder1") Local $IDS_File = _FTP_ListToArrayEx($Conn, 0) ;_ArrayDisplay($IDS_File) $IDS_SIZE = UBound($IDS_File) $IDS_LASTFILE = $IDS_File[$IDS_SIZE -1 ][0] ;MsgBox(1,"tt",$IDS_LASTFILE) _FTP_FileGet($Conn, $IDS_LASTFILE,@ScriptDir & "\data\" & 'IDS_' & $IDS_LASTFILE) Local $Ftpc = _FTP_Close($Open) EndFunc Func ftpgetfile2() Local $server = 'ftp.test.local' Local $username = 'myuser' Local $pass = 'mypass' Local $Open2 = _FTP_Open('MyFTP Control') Local $Conn2 = _FTP_Connect($Open2, $server2, $username2, $pass2,1) _FTP_Command($Conn2,"cwd /folder2") Local $COU_File = _FTP_ListToArrayEx($Conn2, 0) _ArrayDisplay($COU_File) $COU_SIZE = UBound($COU_File) $COU_LASTFILE = $COU_File[$COU_SIZE -1 ][0] ;MsgBox(1,"tt",$COU_LASTFILE) _FTP_FileGet($Conn2, $COU_LASTFILE,@ScriptDir & "\data\" & 'COU_' & $COU_LASTFILE) Local $Ftpc = _FTP_Close($Open2) EndFunc
  23. Hey guys, I got a problem and rly need help. I try using FTP to get a file. Then the content of the file on the FTP-Server is getting changed, and I'm downloading this file again. This works, but the content of the file after downloading it the second time is the same like before...doesn't matter if I open and close the ftp session, or using the same. If I'm using manually FileZilla to get the File it works without any probs. #include <FTPEx.au3>; This line includes all the FTP functions you need. Open this file to see which functions contains exactly. $server = '' $username = '' $pass = '' $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, $username, $pass) $Ftpp = _FTP_FileGet($Conn, '/EDI-Archiv-CD/bin/Status.txt', 'C:\Users\mwenzel\Documents\proUSBPacker\Customers\Status.txt', False, 128, $FTP_TRANSFER_TYPE_ASCII) ;$FTP_TRANSFER_TYPE_BINARY If @error Then ConsoleWrite("ERROR - " & @error & " - " & @extended & " - " & _WinAPI_GetLastErrorMessage() & @CR) $Ftpc = _FTP_Close($Open) MsgBox(0, "", "") $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, $username, $pass) ;~ _FTP_FileGet($l_FTPSession, $s_RemoteFile, $s_LocalFile [, $fFailIfExists = False, [$dwFlagsAndAttributes = 0 [, $l_Flags = 0 [, $l_Context = 0]]]]) $Ftpp = _FTP_FileGet($Conn, '/EDI-Archiv-CD/bin/Status.txt', 'C:\Users\mwenzel\Documents\proUSBPacker\Customers\Status.txt', False, 128, $FTP_TRANSFER_TYPE_ASCII) ;$FTP_TRANSFER_TYPE_BINARY If @error Then ConsoleWrite( Please help me out guys. I need to get this finished :/
  24. 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)

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.