Leaked source code of windows server 2003
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.

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