Jump to content


Perl exemple using 4.1 API Adding a domain

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 Richard Robinson

Richard Robinson
  • Members
  • 0 posts

Posted 01 September 2010 - 04:12 AM

Hello everybody,I got a few exemples of working 4.1 API scripts. So I thought I might share this info since it's hard to find. The following script adds a domain to the Barracuda SF. The code is not mine so I hope whoever wrote it won't mind my post:#!/usr/bin/perluse strict;use warnings;use XML::RPC;print "Enter domain to be added: ";my $domain = <STDIN>;chomp($domain);print "Enter destination server for $domain: ";my $server = <STDIN>;chomp($server);print "...adding domain $domain...with destination server: $servern";#Create the XML::RPC objectmy $xmlrpc = XML::RPC->new ('http://CUDAIP:8000/cgi-mod/api.cgi?password=apipassword');my $result;$result = $xmlrpc->call ('config.create', { parent_type=>'global', parent_path => '', type => 'domain', name =>"$domain", mta_relay_advanced_host => "$server" });# OUTPUTprint "n---XML REQUEST FORMAT EXAMPLE---n";print $xmlrpc->xml_out();print "---XML REQUEST END ---n";print "n---XML RESPONSE EXAMPLE---n";print $xmlrpc->xml_in();print "---XML RESPONSE END---n";Hope this helps.