2009/11/10 Peter Farr <peter.f...@lpi-solutions.com>

> I am trying to install Date-Time-0.51 on an isolated AIX system.


I'm used to work with such isolated systems and I have found workaround to
use live CPAN.
The trick is that I use my desktop (from which I'm connected to the host
with SSH) as a proxy to the entreprise proxy.

Here are the steps:
- setup an HTTP tunnel that listen on port 8130 on the remote machine and
forwards to the entreprise proxy
  In PuTTY, SSH/Tunnels : R127.0.0.1:8130   <proxy_host>:<proxy_port>
- set the environment variable http_proxy to point to it:
  export http_proxy=http://127.0.0.1:8130/

As on those proprietary unixes you usually don't have lynx/curl/wget/LWP, I
wrote a minimalist one that I give to the CPAN Shell (o conf lynx).

#!/usr/bin/perl

use strict;
use warnings;
use IO::Socket;


unless (@ARGV == 2 && $ARGV[0] eq '-source') { die "usage: $0 -source <URL>"
}

my $proxy_url = $ENV{http_proxy};
my ($proxy_host, $proxy_port) = $proxy_url =~ m|http://([^:/]*):(\d+)/?$|;


sub GET($)
{
    my $url = shift;
    my $ret;
    my $remote = IO::Socket::INET->new( Proto     => "tcp",
                                 PeerAddr  => $proxy_host,
                                 PeerPort  => $proxy_port,
                               )
        or die "cannot connect to http proxy on $proxy_host";
    binmode($remote);
    $remote->autoflush(1);

    print $remote "GET $url HTTP/1.0\r\n\r\n";
    my $status_line = <$remote>;
    if ($status_line !~ m|^HTTP/1\.[01] (\d+) (.*)\r|) {
        close $remote;
        print STDERR "Invalid HTTP response!\n";
        return 500;
    }
    my $status = $1+0;
    my $message = $2;

    while ( <$remote> ) { chomp; last if $_ eq "\r"; }
    local $/ = \8192;
    #if ($status == 200) {
        while ( <$remote> ) { print }
    #}
    # TODO Handle redirections

    close $remote;
    return $status;
}

exit(GET($ARGV[1]) != 200);

Reply via email to