Mark H Posted June 13, 2006 Share Posted June 13, 2006 Here is my code greatfully used from other posts and scraps on the site. #include <FTP.au3> $server = 'test' $username = 'test' $pass = 'test' $ftp_dir = '/' $ftp_file_mask = '*.*' $target_dir = 'c:\patchupdates\' $l_flags = '0x08000000' $DownloadNow = MsgBox(4, "Do you want to download the Latest Patches", "Select Yes to continue or No to Quit") If $DownloadNow = 6 Then Download();you don't need to use call Else ; Msgbox(0,"Downloader","unneeded code.") ; Run("OldFile.exe",2) EndIf Func Download() ; ---- Sucht nach der aktuellen Datei ---- ; wird mittels FTP3.au gemacht. ; - FTP.au3 Init - $Open = _FTPOpen('MyFTP Control') If @error Then Failed("Open Failed") $Conn = _FTPConnect($Open, $server, $username, $pass, $l_flags) If @error Then Failed("Connection Failed") Dim $Handle Dim $DllRect $FileInfo = _FtpFileFindFirst($Conn, $ftp_dir & $ftp_file_mask, $Handle, $DllRect) If $FileInfo[0] Then Do ;~ MsgBox(0, "Find", $FileInfo[1] & @CR & $FileInfo[2] & @CR & $FileInfo[3] & @CR & $FileInfo[4] & @CR & $FileInfo[5] & @CR & $FileInfo[6] & @CR & $FileInfo[7] & @CR & $FileInfo[8] & @CR & $FileInfo[9] & @CR & $FileInfo[10]) $dl_file = $FileInfo[10] $FileInfo = _FtpFileFindNext($Handle, $DllRect) Until Not $FileInfo[0] EndIf _FtpFileFindClose($Handle, $DllRect) ; - FTP Verbindung schließen - _FTPClose($Open) ;--------------------------------- ; - ftp-Connect-String bauen ;MsgBox(0,"FTP File", "Lade runter: " & $dl_file) $ftp_conn_string = "ftp://" & $username & ":" & $pass & "@" & $server & $ftp_dir & $dl_file ;you must set progress on before loop ProgressOn("Download " & $dl_file,"", "", -1, -1, 16) InetGet($ftp_conn_string, $target_dir & $dl_file, 1, 1) ; need to divide by 1048576 also, variables that don't change should be outside loop $FileSize = InetGetSize($ftp_conn_string, )/1048576 While @InetGetActive $filedownload = round(@InetGetBytesRead/1048576, 2) $Percent = Round(($filedownload/$FileSize)*100);need to mutliply by 10 to get percentage ProgressSet($Percent,"Downloaded - " & $filedownload & " Mb") TrayTip("Downloading...", "Downloaded = " & $filedownload & " Mb", 10, 16) Sleep(250) Wend ProgressOff() EndFunc ;==>Download ;$Open = _FTPOpen('MyFTP Control') ;$Conn = _FTPConnect($Open, $server, $username, $pass) ;$Ftpp = _FtpGetFile($Conn, 'patches.zip', 'c:\patchfile\patches.zip') ;$Ftpc = _FTPClose($Open) So here is the situation and I'll be damned if I've found a bug in Windows Firewall or what. I have a laptop in which the users only have User capabilities (not even power user). I've written another script to use the RunasSet() and Runwait to execute this program above. I've Added an exception manually for my program and allowed my ftp server's IP into the XP firewall which is enabled to get around the Active FTP issue. What I've run into is that I get an undefined variable when the ftp connects and is unable to list the directories (because XP firewall is blocking port 21 according to the pfirewall.log file) Undefined Variable $ftp_conn_string = "ftp://" & $username & ":" & $pass & "@" & $server & $ftp_dir & $dl_file $ftp_conn_string = "ftp://" & $username & ":" & $pass & "@" & $server & $ftp_dir & ^ERROR If I continue to run the program one right after another, on about the 5th or 6th try it connects and downloads the file with no problem (which is reproducable). I am really confused as to 1 - why i can't get PASV working above and 2 - Why the hell it works if I keep trying...seems like a buffer overflow in the XP firewall or something. If I run with the XP Firewall off, it works everytime. Anyone have any idea's? Link to comment Share on other sites More sharing options...
Daniel W. Posted June 14, 2006 Share Posted June 14, 2006 First this is not the Suppoert forum and then maybe your windows firewall blocks au3 files on connecting to ftps --- --------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote] Link to comment Share on other sites More sharing options...
Mark H Posted June 14, 2006 Author Share Posted June 14, 2006 First this is not the Suppoert forum and then maybe your windows firewall blocks au3 files on connecting to ftps ---Oops, spent too many hours working on it and clicked the wrong area by mistake. Sorry about that.I am compiling into an exe and its an active FTP issue that I am running into. The funny part is that by using a loop I can get the server to suddenly work using active FTP just by retrying multiple times...possibly overflowing the firewall.I've changed my script to use http instead for now until i can figure out the FTP piece. 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