[1533] | 1 | #!/usr/bin/perl -w
|
---|
| 2 |
|
---|
| 3 | ###########################################################################
|
---|
| 4 | #
|
---|
| 5 | # A component of the Greenstone digital library software
|
---|
| 6 | # from the New Zealand Digital Library Project at the
|
---|
| 7 | # University of Waikato, New Zealand.
|
---|
| 8 | #
|
---|
| 9 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 10 | #
|
---|
| 11 | # This program is free software; you can redistribute it and/or modify
|
---|
| 12 | # it under the terms of the GNU General Public License as published by
|
---|
| 13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 14 | # (at your option) any later version.
|
---|
| 15 | #
|
---|
| 16 | # This program is distributed in the hope that it will be useful,
|
---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | # GNU General Public License for more details.
|
---|
| 20 | #
|
---|
| 21 | # You should have received a copy of the GNU General Public License
|
---|
| 22 | # along with this program; if not, write to the Free Software
|
---|
| 23 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 24 | #
|
---|
| 25 | ###########################################################################
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | # This program will download the specified urls (http:, ftp: and file:)
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | BEGIN {
|
---|
| 32 | die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
|
---|
[1743] | 33 | die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
|
---|
[1533] | 34 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
|
---|
| 35 | }
|
---|
| 36 |
|
---|
[1743] | 37 | use util;
|
---|
[28560] | 38 | use FileUtils;
|
---|
[1743] | 39 |
|
---|
| 40 | # wget should live in the Greenstone directory structure
|
---|
| 41 | # we'll bail if we can't find it
|
---|
| 42 | my $exe = &util::get_os_exe ();
|
---|
[28560] | 43 | my $cmd = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wget");
|
---|
[1743] | 44 | $cmd .= $exe;
|
---|
[1533] | 45 | if (! -e "$cmd") {
|
---|
[1743] | 46 | die "gsWget.pl failed: $cmd doesn't exist\n";
|
---|
[1533] | 47 | }
|
---|
| 48 |
|
---|
[2304] | 49 | # if on windows we expect wget to already be on the path -
|
---|
| 50 | # this allows us to avoid problems when GSDLHOME contains spaces
|
---|
| 51 | # (double quoting the call doesn't work on win2000)
|
---|
| 52 | if ($ENV{'GSDLOS'} =~ /^windows$/) {
|
---|
| 53 | $cmd = "wget";
|
---|
| 54 | }
|
---|
| 55 |
|
---|
[28560] | 56 | # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
|
---|
| 57 | &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
|
---|
| 58 |
|
---|
[1533] | 59 | # command-line parameters
|
---|
| 60 | my @quoted_argv = map { "\"$_\"" } @ARGV;
|
---|
| 61 | my $args = join(' ', @quoted_argv);
|
---|
| 62 | $cmd .= " $args";
|
---|
| 63 |
|
---|
| 64 | # run the command
|
---|
| 65 | my $status = system($cmd);
|
---|
| 66 |
|
---|
| 67 | # We should check the error status of wget; unfortunately this
|
---|
| 68 | # is set to 1 even when we exit successfully, so we ignore it.
|
---|
| 69 | #
|
---|
| 70 | #$status /= 256;
|
---|
| 71 | #if ($status != 0) {
|
---|
| 72 | # print STDERR "Error executing $cmd: $!\n";
|
---|
| 73 | # exit($status);
|
---|
| 74 | #}
|
---|
| 75 |
|
---|
| 76 | print "\nDone: $cmd\n";
|
---|