At 16.11 +0100 2000.03.11, Peter Hartmann wrote: >On Tue, 7 Mar 2000 11:43:33 -0500, Chris Nandor <pudge@pobox.com> wrote: > >> At 17.16 +0100 2000.03.07, Carl Johan Berglund wrote: >>>At 13.12 -0500 0-03-03, schinder@pobox.com wrote: >>>>2) use an AppleEvent to ask a browser to do it for you. How you get the >>>>information out of the browser back to your script I don't know. > >[snip] > >> >> The only real problem with this is you don't know for sure when the >> downloading is done. If you want to do user interaction, you can do >> (instead of a sleep): >> >> print "Hit <return> when download is complete:"; <>; >> >> Netscape has a way to tell if a window is busy or whatever, but the dialog >> used for saving URLs to files doesn't do that. > >I know this is a bit late, but this is not quite true. It is >perfectly possible to have Netscape inform your >script/MacPerl/AppleScript that a download is completed. Ah, most excellent, thanks! Callback support is not quite there in Mac::Glue, but we can do it just about as easily without it: #!perl -w use File::Spec::Functions; use Mac::Glue ':all'; use Mac::Events; use strict; my($url, $file, $text, $n, $done); $url = 'https://pause.kbx.de/'; $file = catfile($ENV{TMPDIR}, "pause.html"); $AppleEvent{'WWW?', 'URLE'} = sub { my $dobj = AEGetKeyDesc($_[0], keyDirectObject); my $got = $dobj->get; AEDisposeDesc $dobj; $done++ if $got eq $url; 0; }; $n = new Mac::Glue 'Netscape Communicator'; $n->register_url_echo('McPL'); $n->geturl($url, to => $file); while (1) { last if $done >= 2; WaitNextEvent; } $n->unregister_url_echo('McPL'); { local($/, *F); open F, "< $file" or die "Can't open $file: $!"; ($text = <F>) =~ s/\015?\012/\n/g; } print $text; __END__ -- Chris Nandor mailto:pudge@pobox.com http://pudge.net/ %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6']) # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org