All pastes #1709 Raw Edit

dundiupdate.pl

public text v1 · immutable
#1709 ·published 2004-10-25 18:51 UTC
rendered paste body
#!/usr/bin/perl

#### Settings: ####
## Set this to your local EID
## Eventually, this might get checked from Asterisk
my $LOCAL_EID  = "00:YO:UR:EI:DH:ER";

## Set this to your hostname or IP,
## or blank if you don't want one to show
my $LOCAL_NAME = "your.host.or.ip";

## The command to issue to get your 'dundi show peers'
my $ASTERISK = "asterisk -rx 'dundi show peers'";

## DUNDi Mapping Target (not recommended to change this)
my $TARGET = 'http://vulcan.dmacc.cc.ia.us/dundi/add.cgi';

#### Stop Changing Here ####
my $SHOWPEERS = "";  # This must remain blank

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->agent("DundiUpdate/LWP-1.0");

open F, "$ASTERISK|";
while(<F>) {
  $SHOWPEERS .= $_ if m/^[0-9a-f]/;
}
close F;

my $req = POST $TARGET,
               [ label => $LOCAL_NAME, local_eid => $LOCAL_EID, showpeers => $SHOWPEERS ];
print "Sending the following peer list:\n";
print $SHOWPEERS;
my $resp = $ua->request($req)->content();
if($resp =~ m/^DUNDI_UPDATE_OK/) {
    print "Server Update Successful\n";
} else {
    print "Server Update FAILED\n";
}