OT: Perl Expect Module
Alex Aved
ajaved at anderson.edu
Wed Jul 30 06:43:14 PDT 2003
Fellow listers,
I'm having trouble getting the Expect-1.15 perl module to work (FreeBSD 4.8). What I'm trying to do is to query a dhcp server & given an IP address, return the MAC address using omshell (ISC; www.isc.org). I don't know Perl well enough to interpret where exactly it's failing.
Here's the script I'm trying to run:
>>>>>
use Expect;
use Data::Dumper;
$Expect::Log_Stdout = 1;
my $con = Expect->spawn("/usr/bin/omshell");
$con->debug(1);
$con->send("key defomapi \"secret_key_here\"\n");
$con->send("server _server_ip_here_\nport 7911\n");
$con->send("connect\n");
sleep(1);
$con->send("new lease\nset ip-address = 10.200.0.6\n");
sleep(1);
$con->send("open\n");
print "$con->expect(4, 'hardware-address = ')";
<<<<<
And here's the output when I try to run it interactively:
>>>>>
tallis# perl
use Expect;
use Data::Dumper;
$Expect::Log_Stdout = 1;
my $con = Expect->spawn("/usr/bin/omshell");
$con->debug(1);
$con->send("key defomapi \"secret_key_here\"\n");
$con->send("server _server_ip_here_\nport 7911\n");
$con->send("connect\n");
sleep(1);
$con->send("new lease\nset ip-address = 10.200.0.6\n");
sleep(1);
$con->send("open\n");
print "$con->expect(4, 'hardware-address = ')";
Closing spawn id(3).
Expect::hard_close('Expect=GLOB(0x8114078)') called at /usr/local/lib/perl5/site_perl/5.8.0/Expect.pm line 1575
Expect::DESTROY('Expect=GLOB(0x8114078)') called at - line 0
eval {...} called at - line 0
spawn id(3) closed.
Pid 13079 of spawn id(3) terminated, Status: 0x01
Expect=GLOB(0x8114078)->expect(4, 'hardware-address = ')
tallis#
<<<<<
Any help would be much appreciated!
Thanks,
--alex
More information about the freebsd-questions
mailing list