Sign in to follow this  
Followers 0
obscurant1st

Help with FTP downloader

7 posts in this topic

I have coded a script for ftp downloader.

but it is not working.some error comes up..

can anybody please help me???

I've attached the files.

1. ftp.au3 - to be included in my script.

2. ftp downloader.au3 - my script.

ftp_downloader.au3

ftp.au3

Share this post


Link to post
Share on other sites



Please Read the helpfile.

They way you are handling events is wrong.

#include <GUIConstants.au3>
#include <Array.au3>
;#include "ftp.au3"

$Form1 = GUICreate("FTP Vundo/Monder Downloader", 306, 235, 195, 113)
$server = GUICtrlCreateInput("<server name>", 24, 32, 257, 21)
$username = GUICtrlCreateInput("<user name>", 136, 88, 137, 21)
$pass = GUICtrlCreateInput("<password>", 136, 120, 137, 21)
$Label1 = GUICtrlCreateLabel("Server Name/Address:", 24, 16, 132, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Username:", 64, 90, 64, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Password:", 64, 123, 62, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Connect = GUICtrlCreateButton("Connect", 112, 184, 75, 25, 0)
GUISetState(@SW_SHOW)
$dllhandle = DllOpen('wininet.dll')
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            DllClose($dllhandle)
            Exit
        Case $Connect
            FTPConnection()
    EndSwitch
WEnd

Func FTPConnection()
    $Open = _FTPOpen('Connect to Server')
    $Conn = _FTPConnect($Open, $server, $username, $pass)
    $threatDir = InputBox("Threat Remote Dir", "Enter the Remote Threat Dir:")
    $localDir = InputBox("Local Dir", "Enter the local Path:")
    _FtpSetCurrentDir($Conn, $threatDir)
    Dim $file, $l_Context
    $temp = _FTPFileFindFirst($Conn, $threatDir)
    _ArrayDisplay($temp)
    $file = $temp[10]
    While 1
        _FTPGetFile($Conn, $threatDir & "/" & $file, $localDir & "\" & $file, 2, 0, 0x00000080, 0)
        $file = _FTPFileFindNext($dllhandle, $l_Context)
        If @error Then
            MsgBox(0, "Done!!!", "no More Files to Download")
            _FTPFileFindClose($Conn, $threatDir)
            Exit
        EndIf
    WEnd
    $Ftpc = _FTPClose($Open)
EndFunc  ;==>FTPConnection

;/Public/AutoItScript

Share this post


Link to post
Share on other sites

ok..

but for me error comes when i run the script..

the line in which error comes is

$temp = _FTPFileFindFirst($Conn, $threatDir)

it saying like array size exceeded ..

but how can it be possible since it have only 12 rows and i'm declaring it as temp[12]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

My code snippet shows it as [10]. are you sure you've updated it? I'm not sure, but if the array starts at 1, then you will need ad one to the rows (i.e. [13])

I will come back to you on it, let me just have a look...

Cheers,

Brett

Edited by BrettF

Share this post


Link to post
Share on other sites

I see your using this:

http://www.autoit.de/index.php?page=Thread&postID=48393

I still cannot work out why it is not working like it should. All it returns is "." for a filename!

Maybe ProgAndy will join the topic and tell us whats wrong :D

#include "ftp.au3"

;REMBER TO USE GUICTRLREAD TO GET THE VALUES OF $SERVER, $USERNAME AND $PASS!
$serv = ""
$user = ""
$pass = ""

$hndl = ""
$struct = ""

$FTP = _FTPOpen("AutoIt v3")
$FTPServer = _FTPConnect($FTP, $serv, $user, $pass, 1)

$threatDir = "/"
$localDir = "C:\Test\"
_FtpSetCurrentDir($FTPServer, $threatDir)
Dim $file, $l_Context
$temp = _FTPFileFindFirst($FTPServer, $threatDir, $hndl, $struct, 0, 0)
If IsArray($temp) Then
    While 1
        $filename = $temp[10]
        MsgBox(0, "", $filename)
        If $filename <> "." Then
            MsgBox(0, "", $filename)
            _FTPGetFile($FTPServer, $threatDir & $filename, $localDir & "\" & $file, 2, 0, 0x00000080, 0)
            $temp = _FTPFileFindNext($hndl, $struct)
            If @error Then
                MsgBox(0, "Done!!!", "no More Files to Download")
                _FTPFileFindClose($FTPServer, $threatDir)
                ExitLoop
            EndIf
        EndIf
    WEnd
EndIf

$Ftpc = _FTPClose($FTP)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

m8, i did it..thnk u..bt still got some issues..!!!

the link to my script is

http://www.autoitscript.com/forum/index.ph...mp;#entry663431

pls help me on this also.

Edited by obscurant1st

Share this post


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
Sign in to follow this  
Followers 0