[wellylug] Please recommend a decent ISP. Not IHUG !
Ewen McNeill
ewen at naos.co.nz
Wed Apr 23 10:26:53 NZST 2003
In message <E1983oz-0002Id-00 at israel.diaspora.gen.nz>, michael at diaspora.gen.nz writes:
>Ewen McNeill writes:
>>Michael's script could be quite handy, although I'd prefer to work out a
>>way that didn't involve sticking a password in plain text.
>
>It's not plain text over the wire, because it's http-over-ssl.
True. It is plain text in the file on disk (and the argument list as
you mention) which is the main thing I'd prefer to avoid.
>I looked for a client that would prompt, and be readily available;
>lynx won't prompt, wget (on my system, anyway) won't handle https,
apt-get install w3m-ssl
perhaps? (Yes, it exists, and I have it installed.) I suspect you then
have to run w3m-ssl-en rather than just "w3m" though.
>and lwp-request won't either. Suckie.
apt-get install libcrypt-ssleay-perl libnet-ssleay-perl
will give you a LWP that can do https. Curiously lwp-request still
claims "not implemented". Weird.
Perhaps something like this:
-=- cut here -=-
#! /usr/bin/perl
# Request current traffic information from Paradise
# Free for you to use. If you break it, you own both parts.
BEGIN { delete $ENV{'https_proxy'}; }
use LWP::UserAgent;
use HTTP::Request::Common;
$OUTPUT_FORMAT="%-25s %15s %15s %15s\n";
$name=$ENV{'PARADISE_USER'} || 'ewenmcneill';
if (-t STDIN)
{
print "Enter password: ";
system "stty", "-echo";
chomp($password=<>);
system "stty", "echo";
print "\n";;
}
else
{
chomp($password=<>);
}
$ua = new LWP::UserAgent;
$req = GET "https://www.paradise.net.nz/cgi-bin/member/volume-detail";
$req->authorization_basic($name,$password);
$res = $ua->request($req) or die "Cannot make request";
@ans = split(/\n/, $res->content());
shift @ans while ($ans[0] !~ /Billing Period/);
for (0..1) { $ans[$_] =~ s/<[^>]+>/ /g; $ans[$_] =~ s/\ //g; }
@headings = grep { /\S/ } split(/ /, @ans[0]);
@values = grep { /\S/ } split (/ /, @ans[1]);
@headings[0] = (shift @headings) . " $headings[0]";
@values[0] = (shift @values) . " " . (shift @values) . " $values[0]";
printf $OUTPUT_FORMAT, @headings;
printf $OUTPUT_FORMAT, @values;
-=- cut here -=-
It's a tiny bit unportable, but should be okay on any POSIX system. The
last 7-8 lines are all to do with formatting the answer that comes back.
Someone should teach Paradise about CSS. Or XML-RPC for that matter.
Ewen
More information about the wellylug
mailing list