Ftp upload geht nicht (mit ftp.au3)

  • Was amch ich falsch? das das hier nicht geht..?

    [autoit]


    #include<ftp.au3>

    [/autoit][autoit][/autoit][autoit]

    $server = 'ftp:musterman.de'
    $username = 'User'
    $pass = 'Userpw'

    [/autoit][autoit][/autoit][autoit]

    $Open = _FTPOpen('MyFTP Control')
    $Conn = _FTPConnect($Open, $server, $username, $pass)
    $Ftpp = _FtpPutFile($Conn, 'C:\test.txt', '/ITA-007/Example.exe')
    $Ftpc = _FTPClose($Open)

    [/autoit]
  • oh.. ^^ ups..aber geht immer nicht..
    irgendwas mach ich doch falsch...


    [autoit]


    #include<ftp.au3>

    [/autoit][autoit][/autoit][autoit]

    $server = 'ftp.musterman.de'
    $username = 'User'
    $pass = 'Userpw'

    [/autoit][autoit][/autoit][autoit]

    $Open = _FTPOpen('MyFTP Control')
    $Conn = _FTPConnect($Open, $server, $username, $pass)
    $Ftpp = _FtpPutFile($Conn, 'C:\test.txt', '/Example.txt')
    $Ftpc = _FTPClose($Open)

    [/autoit]
  • lass dir doch mal die Rückgabewerte ausgeben bzw errorcodes und dann kann ja man schon einmal eingrenzen, was den Fehler verursacht

    • Offizieller Beitrag

    Gibt es eigentlich eine offizielle ftp.au3?
    Vermutlich kursieren da unterschiedliche Versionen. Vor einiger Zeit hatte ich auch mal versucht, damit Dateien per FTP zu übertragen und das klappte ebenfalls nicht.
    Ich fand dann eine Funktion, mit der es geklappt hat. Vielleicht hilft Dir das ja auch:

    Spoiler anzeigen
    [autoit]


    ;===================================================================================================
    ; Function Name: _FTPput()
    ;
    ; Description: Uploads a file to an ftp server.
    ;
    ; Parameter(s): $s_p_Host - IP or URL to the host.
    ; (ex. '24.158.58.154')
    ; $s_p_PathFile - The path and filename.
    ; (ex. 'C:\windows\notepad.exe')
    ; $s_p_Acc - Account to log into.
    ; (ex. 'Sander')
    ; $s_p_Pwd - Password for the account.
    ; (ex. 'Monkey')
    ; $s_p_Cd - Path where the file should go to on the server.
    ; (ex. 'uploads\scripts')
    ; $i_p_Check - Enable/Disable download checking.
    ; (ex. 1)
    ; $s_p_Aftp - Additional ftp commands that you want exectued.
    ; (Executed before the send) (Separate commands by @CRLF)
    ; (ex. 'bell')
    ;
    ; Requirement(s): None
    ;
    ; Notes: It is possible to send multiple files using wildcards BUT you will
    ; not be able to check if it was successfull by turning $i_p_Check to 1.
    ;
    ; Return Value(s): ($i_p_Check = 0) (Default)
    ; Always Returns 0
    ;
    ; ($i_p_Check = 1)
    ; On Success - Returns 1
    ; On Failure - Returns -1
    ;
    ; Author(s): (KiXtart) (http://www.kixhelp.com/udfs/udf/83455.htm)
    ; Andrew Mack
    ; Richard H.
    ;
    ; (AutoIt) (Re-Written from scratch)
    ; Wouter Van Kesteren <[email='w0ut3r88@gmail.com'][/email]>
    ;
    ; Example Usage: _FTPput('24.132.95.223', 'C:\WINDOWS\NOTEPAD.EXE', 'uploads', 'fakepass') ;
    ;===================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _FTPput($s_p_Host, $s_p_PathFile, $s_p_Acc, $s_p_Pwd, $s_p_Cd = '', $i_p_Check = 0, $s_p_Aftp = '')

    ; Declaring local variables.
    Local $i_p_Return

    ; Creating a random nummber to minimize the chance of writing to an existing file.
    Local $i_p_Random = Random(100000000, 999999999, 1)

    ; Creating the file.
    Local $h_p_CmdFile = FileOpen(@TempDir & "\FTPcmds" & $i_p_Random & ".txt", 1)

    ; Check if wildcards are used.
    If StringInStr($s_p_PathFile, "*") <> 0 Then $i_p_Check = 0

    ; Getting the path and the filename from $s_p_PathFile.
    Local $s_p_Path = StringTrimRight($s_p_PathFile, StringLen($s_p_PathFile) - StringInStr($s_p_PathFile, "\", 0, -1) + 1)
    Local $s_p_File = StringTrimLeft($s_p_PathFile, StringInStr($s_p_PathFile, "\", 0, -1))

    ; Create an FTP command file if the file is sucsesfully created.
    If $h_p_CmdFile <> -1 Then

    ; Writing the account and password.
    FileWriteLine($h_p_CmdFile, $s_p_Acc & @CRLF)
    FileWriteLine($h_p_CmdFile, $s_p_Pwd & @CRLF)

    ; Set the transfermode to binary
    FileWriteLine($h_p_CmdFile, "binary" & @CRLF)

    ; Additional FTP commands passed to the function are actioned here.
    If $s_p_Aftp <> '' Then FileWriteLine($h_p_CmdFile, $s_p_Aftp & @CRLF)

    ; Making the destination dir if it doesnot exist
    FileWriteLine($h_p_CmdFile, 'mkdir ' & $s_p_Cd & @CRLF)

    ; Set the destination dir if one is given. Else 'root' will be used.
    If $s_p_Cd <> '' Then FileWriteLine($h_p_CmdFile, "cd " & $s_p_Cd & @CRLF)

    ; Set the local directory and send the files.
    FileWriteLine($h_p_CmdFile, "lcd " & $s_p_Path & @CRLF)
    FileWriteLine($h_p_CmdFile, "mput " & $s_p_File & @CRLF)

    ; If $i_p_Check is set to 1 it will get the transferred file back to a check area so we can confirm it worked.
    If $i_p_Check = 1 Then
    FileWriteLine($h_p_CmdFile, "lcd " & @TempDir & @CRLF)
    FileWriteLine($h_p_CmdFile, "mget " & $s_p_File & @CRLF)
    EndIf

    ; Closes the FTP connecetion and exits the FTP program.
    FileWriteLine($h_p_CmdFile, "close" & @CRLF)
    FileWriteLine($h_p_CmdFile, "quit" & @CRLF)

    ; Closes the file.
    FileClose($h_p_CmdFile)

    EndIf

    ; Start FTP with the cmdfile to transfer the file(s) concerned.
    RunWait(@ComSpec & " /c " & 'ftp -v -i -s:' & @TempDir & "\FTPcmds" & $i_p_Random & ".txt " & $s_p_Host, "", @SW_HIDE)

    ; Setting the return value's.
    If $i_p_Check = 1 And Not FileExists(@TempDir & "\" & $s_p_File) Then
    $i_p_Return = -1
    ElseIf $i_p_Check = 1 And FileExists(@TempDir & "\" & $s_p_File) Then
    $i_p_Return = 1
    Else
    $i_p_Return = 0
    EndIf

    ; Delete the temp files.
    FileDelete(@TempDir & "\" & $s_p_File)
    FileDelete(@TempDir & "\FTPcmds" & $i_p_Random & ".txt")

    ; Return the returnvalue.
    Return $i_p_Return

    EndFunc ;==>_FTPput

    [/autoit]

    Die Funktion hatte ich in mein Script eingebunden und damit, wie bereits gesagt, hat das funktioniert.

  • Hi!

    Ich sehe garkein

    [autoit]

    $dllop = DllOpen('wininet.dll')

    [/autoit]

    vor dem FTP Teil und kein

    [autoit]

    DllClose($dllop)

    [/autoit]

    nach dem FTP Upload. Könnte doch gut sein, dass es daran liegt?
    Eine Vermutung :)

    mfG qon