have fun....
http://www.autoit.de/index.php?page=Thread&threadid=158
hm ohja, des schaut toll aus, thx ^^
und wie wende ich das nun an???
so schwer ist es gar nicht also ich hab es so gemacht:
1. zu erst die .ftp.au3 (muss im ordner liegen wird am ende mit in die exe compiled)
hier der source
;FTP UDF, Updated By JohnMC On Aug 17th 2008
;================================================= ==============================
;
; Function Name: _FTPOpen()
; Description: Opens an FTP session.
; Parameter(s): $s_Agent - Random name. ( like "myftp" )
; $l_AccessType - I dont got a clue what this does.
; $s_ProxyName - ProxyName.
; $s_ProxyBypass - ProxyByPasses's.
; $l_Flags - Special flags.
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - Returns an indentifier.
; On Failure - 0 and sets @ERROR
; Author(s): Wouter van Kesteren.
;
;================================================= ==============================
Func _FTPOpen($s_Agent, $l_AccessType = 1, $s_ProxyName = '', $s_ProxyBypass = '', $l_Flags = 0)
dim $handles[6]
$handles[1]=DllOpen("wininet.dll")
Local $ai_InternetOpen = DllCall($handles[1], 'long', 'InternetOpen', 'str', $s_Agent, 'long', $l_AccessType, 'str', $s_ProxyName, 'str', $s_ProxyBypass, 'long', $l_Flags)
If @error OR $ai_InternetOpen[0] = 0 Then
SetError(-1)
Return 0
EndIf
$handles[2]=$ai_InternetOpen[0]
Return $handles
EndFunc ;==> _FTPOpen()
;================================================= ==============================
;
; Function Name: _FTPConnect()
; Description: Connects to an FTP server.
; Parameter(s): $l_InternetSession - Array from _FTPOpen()
; $s_ServerName - Server name/ip.
; $s_Username - Username.
; $s_Password - Password.
; $i_ServerPort - Server port ( 0 is default (21) )
; $l_Service - I dont got a clue what this does.
; $l_Flags - Special flags.
; $l_Context - I dont got a clue what this does.
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1.
; On Failure - 0 and sets @ERROR
; Author(s): Wouter van Kesteren
;
;================================================= ==============================
Func _FTPConnect(ByRef $l_InternetSession, $s_ServerName, $s_Username, $s_Password, $i_ServerPort = 21, $l_Service = 1, $l_Flags = 0, $l_Context = 0)
Local $ai_InternetConnect = DllCall($l_InternetSession[1], 'long', 'InternetConnect', 'long', $l_InternetSession[2], 'str', $s_ServerName, 'int', $i_ServerPort, 'str', $s_Username, 'str', $s_Password, 'long', $l_Service, 'long', $l_Flags, 'long', $l_Context)
If @error OR $ai_InternetConnect[0] = 0 Then
SetError(-1)
Return 0
EndIf
$l_InternetSession[3]=$ai_InternetConnect[0]
Return $ai_InternetConnect[0]
EndFunc ;==> _FTPConnect()
;================================================= ==============================
;
; Function Name: _FTPPutFile()
; Description: Puts an file on an FTP server.
; Parameter(s): $l_FTPSession - Array from _FTPOpen()
; $s_LocalFile - The local file.
; $s_RemoteFile - The remote Location for the file.
; $l_Flags - Special flags.
; $l_Context - I dont got a clue what this does.
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Wouter van Kesteren
;
;================================================= ==============================
Func _FTPPutFile(ByRef $l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0)
Local $ai_FTPPutFile = DllCall($l_FTPSession[1], 'int', 'FtpPutFile', 'long', $l_FTPSession[3], '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()
;================================================= ==================================================
;
; Function Name: _FTPPutFolderContents()
; Description: Puts an folder on an FTP server. Recursivley if selected
; Parameter(s): $l_InternetSession - The Long from _FTPConnect()
; $s_LocalFolder - The local folder i.e. "c:\temp".
; $s_RemoteFolder - The remote folder i.e. '/website/home'.
; $b_RecursivePut - Recurse through sub-dirs. 0=Non recursive, 1=Recursive
; Requirement(s): DllCall, wininet.dll
; Author(s): Stumpii
;
;================================================= ==================================================
Func _FTPPutFolderContents(ByRef $l_FTPSession, $s_LocalFolder, $s_RemoteFolder, $b_RecursivePut)
; Shows the filenames of all files in the current directory.
local $search = FileFindFirstFile($s_LocalFolder & "\*.*")
; Check if the search was successful
If $search = -1 Then
MsgBox(0, "Error", "No files/directories matched the search pattern")
Exit
EndIf
While 1
local $file = FileFindNextFile($search)
If @error Then ExitLoop
If StringInStr(FileGetAttrib($s_LocalFolder & "\" & $file), "D") Then
_FTPMakeDir($l_FTPSession, $s_RemoteFolder & "/" & $file)
If $b_RecursivePut Then
_FTPPutFolderContents($l_FTPSession, $s_LocalFolder & "\" & $file, $s_RemoteFolder & "/" & $file, $b_RecursivePut)
EndIf
Else
_FTPPutFile($l_FTPSession, $s_LocalFolder & "\" & $file, $s_RemoteFolder & "/" & $file, 0, 0)
EndIf
WEnd
; Close the search handle
FileClose($search)
EndFunc ;==>_FTPPutFolderContents
;================================================= ==============================
;
; Function Name: _FTPGetFile()
; Description: Puts an file on an FTP server.
; Parameter(s): $l_FTPSession - Array from _FTPOpen()
; $s_RemoteFile - The remote file.
; $s_LocalFile - The Local Location to download to.
; $l_FailEx - If File Exists Localy 1=Fail 0=Proceed (Default) ;Failing Caused Crash For Me On My Vista Machine -JohnMC
; $l_FlagsA - Special flags & Attributes. -JohnMC
; $l_Flags - Special flags.
; $l_Context - I dont got a clue what this does.
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Dick Bronsdijk
; Updated By JohnMC To Add $l_FailEx and $l_FlagsA
;
;================================================= ==============================
Func _FTPGetFile(ByRef $l_FTPSession, $s_RemoteFile, $s_LocalFile, $l_FailEx = 0, $l_FlagsA = 0, $l_Flags = 0, $l_Context = 0)
Local $ai_FTPGetFile = DllCall($l_FTPSession[1], 'int', 'FtpGetFile', 'long', $l_FTPSession[3], 'str', $s_RemoteFile, 'str', $s_LocalFile, 'long', $l_FailEx, 'long', $l_FlagsA, 'long', $l_Flags, 'long', $l_Context)
If @error OR $ai_FTPGetFile[0] = 0 Then
SetError(-1)
Return 0
EndIf
Return $ai_FTPGetFile[0]
EndFunc;==> _FTPPutFile()
;================================================= ==============================
;
; Function Name: _FTPDelFile()
; Description: Delete an file from an FTP server.
; Parameter(s): $l_FTPSession - Array from _FTPOpen()
; $s_RemoteFile - The remote Location for the file.
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Wouter van Kesteren
;
;================================================= ==============================
Func _FTPDelFile(ByRef $l_FTPSession, $s_RemoteFile)
Local $ai_FTPPutFile = DllCall($l_FTPSession[1], 'int', 'FtpDeleteFile', 'long', $l_FTPSession[3], 'str', $s_RemoteFile)
If @error OR $ai_FTPPutFile[0] = 0 Then
SetError(-1)
Return 0
EndIf
Return $ai_FTPPutFile[0]
EndFunc ;==> _FTPDelFile()
;================================================= ==============================
;
; Function Name: _FTPRenameFile()
; Description: Renames an file on an FTP server.
; Parameter(s): $l_FTPSession - Array from _FTPOpen()
; $s_Existing - The old file name.
; $s_New - The new file name.
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Wouter van Kesteren
;
;================================================= ==============================
Func _FTPRenameFile(ByRef $l_FTPSession, $s_Existing, $s_New)
Local $ai_FTPRenameFile = DllCall($l_FTPSession[1], 'int', 'FtpRenameFile', 'long', $l_FTPSession[3], 'str', $s_Existing, 'str', $s_New)
If @error OR $ai_FTPRenameFile[0] = 0 Then
SetError(-1)
Return 0
EndIf
Return $ai_FTPRenameFile[0]
EndFunc ;==> _FTPRenameFile()
;================================================= ==============================
;
; Function Name: _FTPMakeDir()
; Description: Makes an Directory on an FTP server.
; Parameter(s): $l_FTPSession - Array from _FTPOpen()
; $s_Remote - The file name to be deleted.
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Wouter van Kesteren
;
;================================================= ==============================
Func _FTPMakeDir(ByRef $l_FTPSession, $s_Remote)
Local $ai_FTPMakeDir = DllCall($l_FTPSession[1], 'int', 'FtpCreateDirectory', 'long', $l_FTPSession[3], 'str', $s_Remote)
If @error OR $ai_FTPMakeDir[0] = 0 Then
SetError(-1)
Return 0
EndIf
Return $ai_FTPMakeDir[0]
EndFunc ;==> _FTPMakeDir()
;================================================= ==============================
;
; Function Name: _FTPDelDir()
; Description: Delete's an Directory on an FTP server.
; Parameter(s): $l_FTPSession - Array from _FTPOpen()
; $s_Remote - The Directory to be deleted.
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Wouter van Kesteren
;
;================================================= ==============================
Func _FTPDelDir(ByRef $l_FTPSession, $s_Remote)
Local $ai_FTPDelDir = DllCall($l_FTPSession[1], 'int', 'FtpRemoveDirectory', 'long', $l_FTPSession[3], 'str', $s_Remote)
If @error OR $ai_FTPDelDir[0] = 0 Then
SetError(-1)
Return 0
EndIf
Return $ai_FTPDelDir[0]
EndFunc ;==> _FTPDelDir()
;================================================= ==============================
;
; Function Name: _FTPGetFileSize()
; Description: Gets the file size of a remote file
; Parameter(s): $l_FTPSession - Array from _FTPOpen()
; $s_FileName - Remote file
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): J.o.a.c.h.i.m. d.e. K.o.n.i.n.g.
;
;================================================= ==============================
Func _FTPGetFileSize(ByRef $l_FTPSession, $s_FileName)
Local $ai_FTPGetSizeHandle = DllCall($l_FTPSession[1], 'int', 'FtpOpenFile', 'long', $l_FTPSession[3], 'str', $s_FileName, 'long', 0x80000000, 'long', 0x04000002, 'long', 0)
Local $ai_FTPGetFileSize = DllCall($l_FTPSession[1], 'int', 'FtpGetFileSize', 'long', $ai_FTPGetSizeHandle[0])
If @error OR $ai_FTPGetFileSize[0] = 0 Then
SetError(-1)
Return 0
EndIf
DllCall($l_FTPSession[1], 'int', 'InternetCloseHandle', 'str', $ai_FTPGetSizeHandle[0])
Return $ai_FTPGetFileSize[0]
EndFunc ;==> _FTPGetFileSize()
;================================================= ==============================
;
; Function Name: _FTPGetCurrentDir()
; Description: Get Current Directory on an FTP server.
; Parameter(s): $l_FTPSession - Array from _FTPOpen()
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - Directory Name
; On Failure - 0
; Author(s): Beast
;
;================================================= ==============================
Func _FTPGetCurrentDir(ByRef $l_FTPSession)
Local $ai_FTPGetCurrentDir = DllCall($l_FTPSession[1], 'int', 'FtpGetCurrentDirectory', 'long', $l_FTPSession[3], 'str', "", 'long_ptr', 260)
If @error OR $ai_FTPGetCurrentDir[0] = 0 Then
SetError(-1)
Return 0
EndIf
Return $ai_FTPGetCurrentDir[2]
EndFunc;==> _FTPGetCurrentDir()
;================================================= ==============================
;
; Function Name: _FtpSetCurrentDir()
; Description: Set Current Directory on an FTP server.
; Parameter(s): $l_FTPSession - Array from _FTPOpen()
; $s_Remote - The Directory to be set.
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Beast
;
;================================================= ==============================
Func _FtpSetCurrentDir(ByRef $l_FTPSession, $s_Remote)
Local $ai_FTPSetCurrentDir = DllCall($l_FTPSession[1], 'int', 'FtpSetCurrentDirectory', 'long', $l_FTPSession[3], 'str', $s_Remote)
If @error OR $ai_FTPSetCurrentDir[0] = 0 Then
SetError(-1)
Return 0
EndIf
Return $ai_FTPSetCurrentDir[0]
EndFunc;==> _FtpSetCurrentDir()
;================================================= ==============================
;
; Function Name: _FTPFileFindFirst()
; Description: Find First File on an FTP server.
; Parameter(s): $l_FTPSession - Array from _FTPOpen()
; $s_RemoteFile - The remote file to find
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Dick Bronsdijk
;
;================================================= ==============================
Func _FTPFileFindFirst(ByRef $l_FTPSession, $s_RemoteFile, $l_Flags = 0, $l_Context = 0);, ByRef $h_Handle, ByRef $l_DllStruct
Local $str = "int;uint[2];uint[2];uint[2];int;int;int;int;char[256];char[14]"
$l_FTPSession[4]=DllStructCreate($str)
if @error Then
SetError(-2)
Return ""
endif
Dim $a_FTPFileList[1]
$a_FTPFileList[0] = 0
Local $ai_FTPPutFile = DllCall($l_FTPSession[1], 'int', 'FtpFindFirstFile', 'long', $l_FTPSession[3], 'str', $s_RemoteFile, 'ptr', DllStructGetPtr($l_FTPSession[4]), 'long', $l_Flags, 'long', $l_Context)
If @error OR $ai_FTPPutFile[0] = 0 Then
SetError(-1)
Return $a_FTPFileList
EndIf
$l_FTPSession[5] = $ai_FTPPutFile[0]
$FileName = DllStructGetData($l_FTPSession[4], 9)
Dim $a_FTPFileList[12]
$a_FTPFileList[0] = 12
$a_FTPFileList[1] = DllStructGetData($l_FTPSession[4], 1) ; File Attributes
$a_FTPFileList[2] = DllStructGetData($l_FTPSession[4], 2, 1) ; Creation Time Low
$a_FTPFileList[3] = DllStructGetData($l_FTPSession[4], 2, 2) ; Creation Time High
$a_FTPFileList[4] = DllStructGetData($l_FTPSession[4], 3, 1) ; Access Time Low
$a_FTPFileList[5] = DllStructGetData($l_FTPSession[4], 3, 2) ; Access Time High
$a_FTPFileList[6] = DllStructGetData($l_FTPSession[4], 4, 1) ; Last Write Low
$a_FTPFileList[7] = DllStructGetData($l_FTPSession[4], 4, 2) ; Last Write High
$a_FTPFileList[8] = DllStructGetData($l_FTPSession[4], 5) ; File Size High
$a_FTPFileList[9] = DllStructGetData($l_FTPSession[4], 6) ; File Size Low
$a_FTPFileList[10] = DllStructGetData($l_FTPSession[4], 9) ; File Name
$a_FTPFileList[11] = DllStructGetData($l_FTPSession[4], 10) ; Altername
Return $a_FTPFileList
EndFunc;==> _FTPFileFindFirst()
;================================================= ==============================
;
; Function Name: _FTPFileFindNext()
; Description: Find Next File on an FTP server.
; Parameter(s): $l_FTPSession - Array from _FTPOpen()
; $l_DllStruct -
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Dick Bronsdijk
;
;================================================= ==============================
Func _FTPFileFindNext(ByRef $l_FTPSession)
Dim $a_FTPFileList[1]
$a_FTPFileList[0] = 0
Local $ai_FTPPutFile = DllCall($l_FTPSession[1], 'int', 'InternetFindNextFile', 'long',$l_FTPSession[5], 'ptr', DllStructGetPtr($l_FTPSession[4]))
If @error OR $ai_FTPPutFile[0] = 0 Then
SetError(-1)
Return $a_FTPFileList
EndIf
Dim $a_FTPFileList[12]
$a_FTPFileList[0] = 12
$a_FTPFileList[1] = DllStructGetData($l_FTPSession[4], 1) ; File Attributes
$a_FTPFileList[2] = DllStructGetData($l_FTPSession[4], 2, 1) ; Creation Time Low
$a_FTPFileList[3] = DllStructGetData($l_FTPSession[4], 2, 2) ; Creation Time High
$a_FTPFileList[4] = DllStructGetData($l_FTPSession[4], 3, 1) ; Access Time Low
$a_FTPFileList[5] = DllStructGetData($l_FTPSession[4], 3, 2) ; Access Time High
$a_FTPFileList[6] = DllStructGetData($l_FTPSession[4], 4, 1) ; Last Write Low
$a_FTPFileList[7] = DllStructGetData($l_FTPSession[4], 4, 2) ; Last Write High
$a_FTPFileList[8] = DllStructGetData($l_FTPSession[4], 5) ; File Size High
$a_FTPFileList[9] = DllStructGetData($l_FTPSession[4], 6) ; File Size Low
$a_FTPFileList[10] = DllStructGetData($l_FTPSession[4], 9) ; File Name
$a_FTPFileList[11] = DllStructGetData($l_FTPSession[4], 10) ; Altername
Return $a_FTPFileList
EndFunc;==> _FTPFileFindNext()
;================================================= ==============================
;
; Function Name: _FTPFileFindClose()
; Description: Delete FindFile Structure.
; Parameter(s): $l_FTPSession - Array from _FTPOpen and added onto by _FTPFileFindFirst
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Dick Bronsdijk
;
;================================================= ==============================
Func _FTPFileFindClose($l_FTPSession)
$l_DllStruct=0
Local $ai_FTPPutFile = DllCall($l_FTPSession[1], 'int', 'InternetCloseHandle', 'long', $l_FTPSession[5])
If @error OR $ai_FTPPutFile[0] = 0 Then
SetError(-1)
Return ""
EndIf
Return $ai_FTPPutFile[0]
EndFunc;==> _FTPFileFindClose()
;================================================= ==============================
;
; Function Name: _FTPClose()
; Description: Closes the _FTPOpen session.
; Parameter(s): $l_InternetSession - Array from _FTPOpen()
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Wouter van Kesteren
;
;================================================= ==============================
Func _FTPClose($l_InternetSession)
Local $ai_InternetCloseHandle = DllCall($l_InternetSession[1], 'int', 'InternetCloseHandle', 'long', $l_InternetSession[2])
DLLClose($l_InternetSession[1])
If @error OR $ai_InternetCloseHandle[0] = 0 Then
SetError(-1)
Return 0
EndIf
Return $ai_InternetCloseHandle[0]
EndFunc ;==> _FTPClose()
2t so jetz brauchst du nur noch in deinen skript die befehle zum hochladen
z.B.
#include <.ftp.au3>
$server = 'deinftp.de'
$username = 'deinusername'
$pass = 'dein pw'
$Hand = _FTPOpen('Doesnt Matter')
sleep(1000)
$Ftpc = _FTPConnect($Hand, $server, $username, $pass)
$Ftpp = _FtpGeTFile($Hand, "Ordner vom FTP", "deinedatei.exe")
sleep(1000)
$Ftpc = _FTPClose($Hand)
hoffe ich konnte dir helfen bei weitern fragen kannst du dich mal per pn melden
Powered by vBulletin® Copyright ©2024 Adduco Digital e.K. und vBulletin Solutions, Inc. Alle Rechte vorbehalten.