source: main/trunk/greenstone2/bin/script/gsWget.pl@ 24375

Last change on this file since 24375 was 2304, checked in by sjboddie, 23 years ago

Altered gsWget.pl slightly so that on windows it now relies on wget.exe
being on the path rather than giving an explicit path to the system call.
This avoids annoying inconsistencies on different windows platforms (e.g.
a system call to "c:\program files\gsdl\bin\windows\wget.exe" won't work
on windows 2000 -- the same call without quotes will fail on all platforms)

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
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
31BEGIN {
32 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
33 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
34 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
35}
36
37use util;
38
39# wget should live in the Greenstone directory structure
40# we'll bail if we can't find it
41my $exe = &util::get_os_exe ();
42my $cmd = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wget");
43$cmd .= $exe;
44if (! -e "$cmd") {
45 die "gsWget.pl failed: $cmd doesn't exist\n";
46}
47
48# if on windows we expect wget to already be on the path -
49# this allows us to avoid problems when GSDLHOME contains spaces
50# (double quoting the call doesn't work on win2000)
51if ($ENV{'GSDLOS'} =~ /^windows$/) {
52 $cmd = "wget";
53}
54
55# command-line parameters
56my @quoted_argv = map { "\"$_\"" } @ARGV;
57my $args = join(' ', @quoted_argv);
58$cmd .= " $args";
59
60# run the command
61my $status = system($cmd);
62
63# We should check the error status of wget; unfortunately this
64# is set to 1 even when we exit successfully, so we ignore it.
65#
66#$status /= 256;
67#if ($status != 0) {
68# print STDERR "Error executing $cmd: $!\n";
69# exit($status);
70#}
71
72print "\nDone: $cmd\n";
Note: See TracBrowser for help on using the repository browser.