#!/usr/bin/perl
## CALL MODULES
use strict;
use warnings;
use Net::OpenSSH;
## SET VARIABLES
my $host = 'host';
my $user = 'user';
my $pass = 'pass';
my ($ssh, $out, $in, $pid);
my ($message);
## OPEN THE SSH SESSION
$ssh = Net::OpenSSH->new($host, user=>$user, password=>$pass);
$ssh->error and die "unable to connect to remote host: " . $ssh->error;
($out, $in, undef, $pid) = $ssh->open_ex( { stdin_pipe=>1, stdout_pipe=>1, ssh_opts=>'-s'},'xmlagent' ) or die "open_ex failed: " . $ssh->error;
## SEND THE CLIENT HELLO
$message = qq~
urn:ietf:params:xml:ns:netconf:base:1.0
]]>]]>~;
print $out $message;
## SEND THE QUERY FOR THE ARP TABLE
$message = qq~
]]>]]>~;
print $out $message;
## PRINT THE RESULTS
while (<$in>)
{
print;
last if $_ =~ m/\/nf:rpc-reply/;
};
waitpid($pid, 0);
exit;