if its cisco a router, here is a nasty trick that worked for me...
$exp->send("$cmd");
$exp->send("!");
then wait for "routerprompt>!" in $exp->expect
let us know if worked for you :)
Good luck
Juan Pablo
On Fri, Nov 20, 2009 at 1:40 PM, Zed <zed...@gm...> wrote:
> Hello. I'm trying to use perl Expect to fetch a large (500k or so)
> configuration dump from a router via ssh. I wrote a small sub to help:
>
> sub SendExpect
> {
> my $cmd = shift;
> my $pat = shift;
>
> $exp->send("$cmd");
> $exp->expect($C_timeout, '-re', $pat?$pat:$prompt);
>
> return $exp->before();
> }
>
> I call this sub to send a few admin commands first, which return output
> as expected. I then send the command to dump the full router config. The
> call to SendExpect returns only the first 150k or so of the config,
> sometimes as much as 170k, sometimes only about 100k.
>
> The next call to SendExpect sends another admin command. However, this
> call returns more of the router config from the previous call, not the
> output of the admin command.
>
> I can't figure out what I'm doing wrong here or how to fix it. Can
> anyone help me?
>
> Thanks.
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Expectperl-discuss mailing list
> Exp...@li...
> https://lists.sourceforge.net/lists/listinfo/expectperl-discuss
>
|