Jump to content

Recommended Posts

Posted

hi all,

i've got a problem with the following autoit program.

i'm downloading 2 files from a ftp server, the 2 files are prefectly received, i've got my end message box but the program continues to run for a few minutes.

i don't understand why this occurs...

do you think it's possible to fix this problem?

here is my code:

CODE

DownloadFile("test2.acv")

DownloadFile("installation.doc")

msgbox(0,"","end")

Func DownloadFile($file)

dim $dl_file,$server,$username,$pass,$tmp,$netDnFileSize

$server = 'myserver'

$username = 'myusername'

$pass = 'mypassword'

ProgressOn('Downloading ' & $file, $file)

$netDnFileSize = InetGetSize("ftp://" & $username & ":" & $pass & "@" & $server & "/FTP/_VP_SYSTEM/" & $file)

InetGet("ftp://" & $username & ":" & $pass & "@" & $server & "/FTP/_VP_SYSTEM/" & $file, "c:\" & $file, 0,1)

While @InetGetActive

ProgressSet((@InetGetBytesRead / $netDnFileSize) * 100, 'Downloading', Round((@InetGetBytesRead / $netDnFileSize) * 100) & '% downloaded')

Sleep(250)

Wend

ProgressOff()

EndFunc

Posted

sorry, you'll find here after the code between autoit tags.

i put all this code in 1 file named test.au3, there is no other lines of code in this file.

i launch it by doing an F5 in SCITE, everything goes well except that the process "test.exe" is still visible in the task manager during a few minutes, and all the items of the tools menu are disabled except the "Stop Executing" one during this time.

DownloadFile("test2.acv")
DownloadFile("installation.doc")
msgbox(0,"","end")

Func DownloadFile($file)
    dim $dl_file,$server,$username,$pass,$tmp,$netDnFileSize

    $server = 'myserver'
    $username = 'myusername'
    $pass = 'mypassword'

    ProgressOn('Downloading ' &  $file, $file)
    $netDnFileSize = InetGetSize("ftp://" & $username & ":" & $pass & "@" & $server & "/FTP/_VP_SYSTEM/"& $file)
    
    InetGet("ftp://" & $username & ":" & $pass & "@" & $server & "/FTP/_VP_SYSTEM/" & $file, "c:\"  & $file, 0,1)

    While @InetGetActive
        ProgressSet((@InetGetBytesRead / $netDnFileSize) * 100, 'Downloading', Round((@InetGetBytesRead / $netDnFileSize) * 100) & '% downloaded')
        Sleep(250)
    Wend

    ProgressOff()
EndFunc
Posted

Can you make a test script that downloads a file on a public server? In other words, something I can run out of the box.

Posted (edited)

i had the same problem months ago as it seems some ftp sites dont return a "completed" command so it awaits ftp timeout instead.

The way i got around it was to autoexecute another script within my script to download the file, then on successfull download processclose the 2nd script, which then disconnected from ftp.

Edited by Rick

Who needs puzzles when we have AutoIt!!

Posted

hi valik,

you'll find here after the same script but the test is made on a public server (debian), i've got the same problem.

DownloadFile("rescue.bin")
msgbox(0,"","end")

Func DownloadFile($file)
    dim $dl_file,$server,$username,$pass,$tmp,$netDnFileSize

    $server = 'ftp.fr.debian.org/debian/dists/woody/main/disks-i386/current/images-1.44/bf2.4'
    $username = ''
    $pass = ''

    ProgressOn('Downloading ' &  $file, $file)
    $netDnFileSize = InetGetSize("ftp://" & $username & ":" & $pass & "@" & $server & "/"& $file)
    
    InetGet("ftp://" & $username & ":" & $pass & "@" & $server & "/" & $file, "c:\"  & $file, 0,1)

    While @InetGetActive
        ProgressSet((@InetGetBytesRead / $netDnFileSize) * 100, 'Downloading', Round((@InetGetBytesRead / $netDnFileSize) * 100) & '% downloaded')
        Sleep(250)
    Wend

    ProgressOff()
EndFunc
Posted

hi valik,

you'll find here after the same script but the test is made on a public server (debian), i've got the same problem.

Actually, I do see a small problem with the code, although it's probably not causing the problem. You're not checking if @InetGetBytesRead is returning an error (-1):

DownloadFile("rescue.bin")
msgbox(0,"","end")

Func DownloadFile($file)
    dim $dl_file,$server,$username,$pass,$tmp,$netDnFileSize

    $server = 'ftp.fr.debian.org/debian/dists/woody/main/disks-i386/current/images-1.44/bf2.4'
    $username = ''
    $pass = ''

    ProgressOn('Downloading ' &  $file, $file)
    $netDnFileSize = InetGetSize("ftp://" & $username & ":" & $pass & "@" & $server & "/"& $file)
    
    InetGet("ftp://" & $username & ":" & $pass & "@" & $server & "/" & $file, "c:\"  & $file, 0,1)

    While @InetGetActive
        If @InetGetBytesRead = -1 Then
                ExitLoop
        EndIf
        ProgressSet((@InetGetBytesRead / $netDnFileSize) * 100, 'Downloading', Round((@InetGetBytesRead / $netDnFileSize) * 100) & '% downloaded')
        Sleep(250)
    Wend
    InetGet( 'abort' )
    ProgressOff()
EndFunc

I also added InetGet("abort") to try to force InetGet to stop which may fix the problem!

Posted

The script works fine for me. It doesn't hang. You've neglected to mention what version of Windows, AutoIt and Internet Explorer you are using.

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.
×
×
  • Create New...