Sign in to follow this  
Followers 0
lanlau

inetGet : Execution continues after the program's end

8 posts in this topic

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

Share this post


Link to post
Share on other sites



I don't see anything wrong with the code, but please use "autoit" tags instead of "code" tags for AutoIt code.

My guess is maybe some leftover shutdown?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#5 ·  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!!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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.

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