Hey all I am having some trouble with
Expect::Simple and need to get some advice or direction from you all on what I am doing wrong. I am trying to use this module to log into a remote Layer4 load balancer and roll device (servers) in and out of production, but for some reason I am not getting what I want right now below in my code thus far and what errors I am seeing.
Code:
#!/usr/bin/perl -Tw
# This is a wrapper script that will use Expect
# to telnet to the VIP changer for PHX and roll
# in and out of prod for service reasons
use strict;
use Expect::Simple;
my $obj = new Expect::Simple {
Cmd => "telnet my.host.com verbose=1",
Prompt => 'Enter Password',
DisconnectCmd => 'quit',
Verbose => 0,
Debug => 0,
Timeout => 100
};
$obj->send( my $cmd );
print $obj->before;
print $obj->after;
print $obj->match_str, "\n";
print $obj->match_idx, "\n";
print $obj->error_expect;
print $obj->error;
my $expect_object = $obj->expect_handle;
Here is what I get in error:
Expect::Simple: Expect::Simple: couldn't find prompt
at ./vipPHX.cgi line 11
at ./vipPHX.cgi line 11
print() on closed filehandle GEN0 at /opt/HWPerl/lib/perl5/5.8.0/sun4-
+solaris/IO/Handle.pm line 395.
print() on closed filehandle GEN0 at /opt/HWPerl/lib/perl5/5.8.0/sun4-
+solaris/IO/Handle.pm line 395.
I am lost and do not know where to go from here, does anyone have a beeter example of using this module??
Thanks all
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.