3-66
User Guide for Resource Manager Essentials 4.1
OL-11714-01
Chapter 3 Adding and Troubleshooting Devices Using Device Management
Device List Manipulation Service
out = out + line + "\n";
}
} catch (IOException e) {
pw.println("Error in fileToString: " + e.getMessage());
return null;}
return out;}
public synchronized void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doGet(req,res);}
}
PERL Example
This is an example of PERL code that calls the Device List Manipulation Service URL and passes in the
content of an XML file.
#!/opt/CSCOpx/bin/perl
# Sample perl script to use Device List Manipulation API.
# The return information from the API is printed out to STDOUT.
use LWP::UserAgent;
my $myInput = "";
my $url;
my $DevListSvc = '/rme/com.cisco.nm.rmeng.inventory.servlet.DeviceListService';
my $fileLoc = "/opt/CSCOpx/example/show.xml";
my $server = 'CiscoWorks-Server';
my $port = '1741';
open xmlFILE, $fileLoc or die "Can't find file $fileLoc: $!\n";
while (<xmlFILE>) {
$myInput .= $_;
}
$url = 'http://' . $server . ':' . $port . $DevListSvc;
$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);
### Create a request
my $request = new HTTP::Request POST => $url;
$request->content_type('application/x-www-form-urlencoded');
$request->content($myInput);
my $response = $ua->request($request);
### Check the outcome of the response
if ($response->is_success) {