Jump to content

Recommended Posts

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)
    MsgBox($MB_SYSTEMMODAL, 'FTP Connection : ', 'Connected')
Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)


SOLVED missed to add #RequireAdmin

Edited by akira2891
Link to post
Share on other sites

Now have same problem with GUI but all works fine just dont want to connect again throws error -1, i try to compile ( x64 ) and run as admin, try to run script just in x64

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <FTPEx.au3>

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#Region ### START Koda GUI section ###
$GUI = GUICreate("FTP tool", 308, 242, 643, 265)
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)
#EndRegion ### END Koda GUI section ###

If GUICtrlRead($status) = 'Not connected' Then GUICtrlSetState($disconnectBtn, $GUI_DISABLE) ; disable disconnect button
GUICtrlSetData($port, '21') ; default port

Global $status, $host, $port, $username, $password

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Case $connectBtn


; 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, GUICtrlRead($_host), GUICtrlRead($_username), GUICtrlRead($_password), "", GUICtrlRead($_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
            MsgBox(48, 'FTP connection error', "Can't connect to server, error = " & @error) ; if there is connection error
            MsgBox(48, 'Test variables', 'server name = ' & $_host & ', username = ' & $_username & ', password = ' & $_password & ', port = ' & $_port) ; debugg message



SOLVED mistake was that i read here already filled variables

Local $FTPConnect = _FTP_Connect($FTPopen, GUICtrlRead($_host), GUICtrlRead($_username), GUICtrlRead($_password), "", GUICtrlRead($_port)) ; connect

; need to be

Local $FTPConnect = _FTP_Connect($FTPopen, $_host, $_username, $_password, "", $_port) ; connect


Edited by akira2891
Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By mLipok
      I want to present BETA Version of my ADO.au3 UDF.
      This is modifed version of _sql.au3 UDF.
      For that I want to thanks : ; Chris Lambert, eltorro, Elias Assad Neto, CarlH
      This is first public release , and still is as BETA
      DOWNLOAD LINK (in download section): 
      Have fun,
      EDIT: 2016-06-03
      Below some interesting topics about databases:
      EDIT 2016/07/04:
      For more info about ADO look here:
      FOR EXAMPLE DATABASE use AdventureWorksDW2016_EXT.bak from:
      I will relay on this database in my examples.
      Here is link to post which shows how "ODBC Data Source Administrator" looks like.
    • By wysocki
      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.
    • By Dent
      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  
    • By Raywando
      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. 
    • By Carm01
      I am attempting to pull a list of the directory structure from a public FTP where no username or password is required i.e:
      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
  • Create New...