Perl to Omshell. I can Create but not Remove.
martin at dc.cis.okstate.edu
Tue Apr 26 20:55:36 UTC 2011
I found a good sample script that demonstrates using perl
scripts to add and hopefully delete static entries. The reason I
say hopefully is that while I had no trouble creating what is
essentially a bootP entry, I can't seem to delete it.
Here is the sample script and my thanks to the person who
originally created it. It works exactly as it should and an
entry reflecting one's input does show up in the dhcpd.leases
print "Please enter the MAC address of the client interface.\n";
my $mac = <STDIN>;
print "Please enter the IP address.\n";
my $ip = <STDIN>;
print "Please enter a name for this client.\n";
my $name = <STDIN>;
open (OMSHELL, "|omshell") || die ("Unable to open omshelln");
print OMSHELL "server 22.214.171.124\n";
#print OMSHELL "port 9991\n";
print OMSHELL "key dccontrol \"LPMVCPjsgymPUnN5cyhKRs+necqdxRQpR6YSo8ZNljWfQpsZJy1+ttbI/XtMEhvQRCkDN5tTVgeJzjOoHIL4sg==\"\n";
print OMSHELL "connect\n";
print OMSHELL "new host\n";
print OMSHELL "set name = \"$name\"\n";
print OMSHELL "set hardware-address = $mac\n";
print OMSHELL "set hardware-type = 1\n";
print OMSHELL "set ip-address = $ip\n";
print OMSHELL "create\n";
close (OMSHELL) || die "Unable to close omshell.\n";
The script that does not work is the exact same script as above
except for the word remove instead of creat.
The error from omshell is that the object can not be
destroied as it can not be found.
> can't destroy object: not found
name = "testq.it.okstate.edu"
hardware-address = 00:aa:bb:cc:dd:ee
hardware-type = 1
ip-address = 8b:4e:06:c3
I even used a file to contain all the input so that there was no
chance of a typo in the removal attempt that would make the
I have actually used omshell under an expect script and
removed many bootP hosts. Any idea as to why the perl script
is not allowing the removal?
Martin McCormick WB5AGZ Stillwater, OK
OSU Information Technology Department Telecommunications Services Group
More information about the dhcp-users