Thread ActiveState PPM Mirror (3 answers)
Opened by esskar at 2004-03-19 04:44

esskar
 2004-03-19 04:44
#81141 #81141
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
mir sit gerade eingefallen, dass ich am Wochenende zwar nen Laptop bei unserer Firmenfahrt dabei hab, aber im Hotel wohl nicht online bin.
Deswegen hab ich grad schnell noch ein Script geschrieben, dass mir ActiveState's PPMs spiegelt

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl

use strict;
use warnings;

use LWP::Simple;
use LWP::UserAgent;

my $ppmserverurl = "http://ppm.activestate.com/PPMPackages/zips/8xx-builds-only/Windows/";
my $ppmlocalfolder = "d:/ppm_mirror/";

die "[$ppmlocalfolder] does not exists." unless $ppmlocalfolder;

my $header = qq~<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Index of /PPMPackages/zips/8xx-builds-only/Windows</title>
</head>
<body>
<h1>Index of /PPMPackages/zips/8xx-builds-only/Windows</h1>
<ul><li><a href="/PPMPackages/zips/8xx-builds-only/"> Parent Directory</a></li>~;

my $footer = qq~</ul>
</body></html>~;

my $page = get($ppmserverurl);

$page =~ s!^$header!!;
$page =~ s!$footer$!!;

my @lines = split /\r?\n/, $page;

my $ua = LWP::UserAgent->new(env_proxy => 1, keep_alive => 1, timeout => 30);

foreach my $line (@lines)
{
chomp $line;
next unless $line;
$line =~ m!<a href="(.*)"> (.*)</a>!i;

my ($file, $desc) = ($1, $2);
next unless $file and $desc;

my $source = "$ppmserverurl$file";
my $dest = "$ppmlocalfolder$file";

print "Mirror [$source] -> [$dest]\n";
$ua->mirror($source, $dest);
}


ist nicht perfekt; tut aber was es soll...

wer will, kann es gerne verbessern...
also, bis montag...

sk

View full thread ActiveState PPM Mirror