I want to create a simple Perl script to determine and display the status of an ISC DHCP failover pair using omapi and omshell. What I have so far:
#!/usr/bin/perl
use strict;
open(OMSHELL, "|/bin/omshell") || die("Could not open omshell\n");
print OMSHELL "server localhost\n";
print OMSHELL "port 6902\n";
print OMSHELL "key omapi_key fakekey==\n";
print OMSHELL "connect\n";
print OMSHELL "new failover-state\n";
print OMSHELL "set name = \"netreg-failover\"\n";
print OMSHELL "open\n";
close(OMSHELL) || die("Could not close omshell\n");
This works in that it prints a list of dhcpd status messages once it hits the open command. However, instead of display the output on screen, I want to parse it, capture a few lines and do some processing. I don't know how to both open omshell to enter commands and read the output instead of displaying it. I hope that makes sense. I tried searching for the correct way to do it but couldn't wrap my head around the examples I've looked at.
-Mike