lanlau Posted December 15, 2006 Share Posted December 15, 2006 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 Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 15, 2006 Share Posted December 15, 2006 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? Link to comment Share on other sites More sharing options...
lanlau Posted December 15, 2006 Author Share Posted December 15, 2006 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 Link to comment Share on other sites More sharing options...
Valik Posted December 15, 2006 Share Posted December 15, 2006 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. Link to comment Share on other sites More sharing options...
Rick Posted December 16, 2006 Share Posted December 16, 2006 (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 December 16, 2006 by Rick Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
lanlau Posted December 18, 2006 Author Share Posted December 18, 2006 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 Link to comment Share on other sites More sharing options...
JerryD Posted December 18, 2006 Share Posted December 18, 2006 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! Link to comment Share on other sites More sharing options...
Valik Posted December 18, 2006 Share Posted December 18, 2006 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now