Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <436E995A.1F02F761@dessent.net> Date: Sun, 06 Nov 2005 16:01:30 -0800 From: Brian Dessent MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: where is setup.exe source? References: <436E6A0C DOT 5E565962 AT dessent DOT net> <436E7DCC DOT 6E27EA9 AT dessent DOT net> <436E891A DOT 489A09B5 AT dessent DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Brian Dessent wrote: > Maybe a starting point would be a awk[1] script that lives in the > base-files package that grabs mirrors.lst and downloads some relatively > small package from every mirror, and generates a report. That way, we > could at least say "try running mirror-check.awk" when users have > problems with mirrors, rather than just "play around until you find a > mirror you like." Here is a first stab at such a script. It gets mirrors.lst and then downloads setup.bz2 from each http mirror and reports the elapsed time. It doesn't sort the results or anything, but I just wanted to see if it was possible to do this in gawk. #!/usr/bin/awk -f BEGIN { CygwinSite = "/inet/tcp/0/cygwin.com/80" MirrorsUrl = "http://cygwin.com/mirrors.lst" RS = ORS = "\r\n\r\n" print "GET " MirrorsUrl " HTTP/1.0" |& CygwinSite CygwinSite |& getline Header if (Header !~ /^HTTP\/1\.[10] 2[0-9][0-9]/) { printf "Error fetching %s. Response was:\n%s\n", MirrorsUrl, Header exit } RS = ORS = "\n" while ((CygwinSite |& getline Mirror) > 0) { split(Mirror, Fields, ";") if (Fields[1] ~ /^http:\/\//) { AwkFetch = "/bin/time /bin/awk 'BEGIN { site = \"/inet/tcp/0/" \ Fields[2] "/80\"; RS = ORS = \"\\r\\n\\r\\n\"; print \"GET " \ Fields[1] "/setup.bz2 HTTP/1.0\" |& site; while " \ "((site |& getline) > 0); close (site); }' 2>&1" while((AwkFetch | getline Output) > 0) { if (match(Output, /([0-9]+:[0-9]+\.[0-9]+)elapsed/, Elap)) { printf "Mirror %s (located in %s, %s) time %s\n", \ Fields[2], Fields[4], Fields[3], Elap[1] break } } close(AwkFetch) } } close(CygwinSite) } Obviously this is pretty rough (no ftp: support, assumes port :80 instead of parsing it from the URL, etc.) And it would be a lot prettier in perl or something but the whole reason for this exercise was to see if it was possible to write a script in pure awk that could do this. Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/