List domains of a customer


#!/usr/bin/perl
use LWP::UserAgent;
use
Data::Dumper;

my $dmapiURL = "https://dmapi.joker.com/request";

my $ua
= LWP::UserAgent-> new;

my $req
= HTTP::Request-> new(GET => $dmapiURL.'/login?username='.shift().'&password='.shift());
my $res = $ua-> request($req);

unless ($res-> is_success) {
print
"Failed: ", $res-> status_line, "n";
exit -
1;
}

my $auth=$res-> as_string;
my $output;

if ($auth =~ /Auth-Sid:s*(w+)/ms) {
$req=HTTP::Request-> new(GET => $dmapiURL.'/query-domain-list?auth-sid='.$1);
$res = $ua-> request($req);
if (
$res-> is_success) {
$output=$res-> content;
}

else{
print
"Failed: ", $res-> status_line, "n";
exit -
2;
}
}

else {
print
"Failed: Got no auth-id from DMAPI:n";
print
$res-> content;
exit -
3;
}


my @lines=split ("n",$output);
my $month=now + ("2M");
my %list;

my $p=0;
for
my $line(@lines) {
#Skip first line
next unless $p or $line =~ /^s*$/;
unless ($p) { $p=1; next};
my ($fqdn,$exp)=split ("[ t]+",$line);
$list{$fqdn}=$exp;
}

for (sort keys %list) {
print
"$_n";
}

 

Tags: customer, domains, list, perl

Related entries:

You cannot comment on this entry