The get_chassis_inventory.pl script retrieves and displays a detailed inventory of the hardware components installed in a routing platform. It is equivalent to issuing the show chassis hardware detail command.
After establishing a connection to the JUNOScript server, the script defines get_chassis_inventory as the request to send and includes the detail argument:
my $query = "get_chassis_inventory";
my %queryargs = ( detail => 1 );
The script sends the query and assigns the results to the $res variable. It performs two tests on the results, and prints an error message if it cannot send the request or if errors occurred when executing it. If no errors occurred, the script uses XSLT to transform the results. For more information, see Parsing and Formatting an Operational Response.
my $res = $jnx->$query( %queryargs );
unless ( ref $res ) {
die "ERROR: $deviceinfo{hostname}: failed to execute command $query.\n";
}
my $err = $res->getFirstError(????);
if ($err) {
print STDERR "ERROR: $deviceinfo{'hostname'} - ", $err->{message}, "\n";
} else {
... code that uses XSLT to process results ...
}