Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
2.7 KiB

  1. @rem = '--*-Perl-*--
  2. @echo off
  3. if "%OS%" == "Windows_NT" goto WinNT
  4. perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. goto endofperl
  6. :WinNT
  7. perl -x -S "%0" %*
  8. if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
  9. if %errorlevel% == 9009 echo You do not have Perl in your PATH.
  10. goto endofperl
  11. @rem ';
  12. #!perl -w
  13. #line 14
  14. # $Id: lwp-mirror.PL,v 1.19 1999/09/15 19:42:19 gisle Exp $
  15. #
  16. # Simple mirror utility using LWP
  17. =head1 NAME
  18. lwp-mirror - Simple mirror utility for WWW
  19. =head1 SYNOPSIS
  20. lwp-mirror [-v] [-t timeout] <url> <local file>
  21. =head1 DESCRIPTION
  22. This program can be used to mirror a document from a WWW server. The
  23. document is only transfered if the remote copy is newer than the local
  24. copy. If the local copy is newer nothing happens.
  25. Use the C<-v> option to print the version number of this program.
  26. The timeout value specified with the C<-t> option. The timeout value
  27. is the time that the program will wait for response from the remote
  28. server before it fails. The default unit for the timeout value is
  29. seconds. You might append "m" or "h" to the timeout value to make it
  30. minutes or hours, repectively.
  31. Because this program is implemented using the LWP library, it only
  32. supports the protocols that LWP supports.
  33. =head1 SEE ALSO
  34. L<lwp-request>, L<LWP>
  35. =head1 AUTHOR
  36. Gisle Aas <[email protected]>
  37. =cut
  38. use LWP::Simple qw(mirror is_success status_message $ua);
  39. use Getopt::Std;
  40. $progname = $0;
  41. $progname =~ s,.*/,,; # use basename only
  42. $progname =~ s/\.\w*$//; #strip extension if any
  43. $VERSION = sprintf("%d.%02d", q$Revision: 1.19 $ =~ /(\d+)\.(\d+)/);
  44. $opt_h = undef; # print usage
  45. $opt_v = undef; # print version
  46. $opt_t = undef; # timeout
  47. unless (getopts("hvt:")) {
  48. usage();
  49. }
  50. if ($opt_v) {
  51. require LWP;
  52. my $DISTNAME = 'libwww-perl-' . LWP::Version();
  53. die <<"EOT";
  54. This is lwp-mirror version $VERSION ($DISTNAME)
  55. Copyright 1995-1999, Gisle Aas.
  56. This program is free software; you can redistribute it and/or
  57. modify it under the same terms as Perl itself.
  58. EOT
  59. }
  60. $url = shift or usage();
  61. $file = shift or usage();
  62. usage() if $opt_h or @ARGV;
  63. if (defined $opt_t) {
  64. $opt_t =~ /^(\d+)([smh])?/;
  65. die "$progname: Illegal timeout value!\n" unless defined $1;
  66. $timeout = $1;
  67. $timeout *= 60 if ($2 eq "m");
  68. $timeout *= 3600 if ($2 eq "h");
  69. $ua->timeout($timeout);
  70. }
  71. $rc = mirror($url, $file);
  72. if ($rc == 304) {
  73. print STDERR "$progname: $file is up to date\n"
  74. } elsif (!is_success($rc)) {
  75. print STDERR "$progname: $rc ", status_message($rc), " ($url)\n";
  76. exit 1;
  77. }
  78. exit;
  79. sub usage
  80. {
  81. die <<"EOT";
  82. Usage: $progname [-options] <url> <file>
  83. -v print version number of program
  84. -t <timeout> Set timeout value
  85. EOT
  86. }
  87. __END__
  88. :endofperl