well i tried again when i came in this morning and voila! everything works just fine.

thank you all for your inputs. i'm just going to chalk it up to the fact it's a vm running on a m$oft box and after the reboot everything is happy happy. :-)

i've made a couple of mods to what i had and below is my working copy...
#! /usr/bin/perl use strict; use warnings; use Net::OpenSSH; use Expect; use IO::Stty; use DateTime; use Creds qw($user $pass $enpass); my $logpath = '/var/log/myssh/'; my $host = $ARGV[0]; my $timeout = 5; my $connstr="$user:$pass\@$host"; my $dt = DateTime->now(time_zone=>'local'); my $log = $logpath.$host."-".$dt->datetime(); my $ssh = Net::OpenSSH->new("$connstr", timeout => 10); $ssh->error and die "unable to connect to host: ". $ssh->error; my ($pty, $pid) = $ssh->open2pty(); my $expect = Expect->init($pty); $expect->log_file($log); $expect->expect($timeout, [ '>' => sub { $expect->send('enable'); $expect->send("\r"); $expect->expect('Password:'); $expect->send($enpass); $expect->send("\r") ; $expect->expect('-re', '/\w+[#]\s/'); } ], [ '#' ], ); $expect->interact(); `gzip $log`;

it's working well enough for authenticating to cisco devices, going to enable mode, and logging the session. admittedly it needs a bit more spit and polish, but first i'm gonna get more caffeine.

happy coding!!


In reply to Re: EXPORT and Net::Openssh by th'timmay
in thread EXPORT and Net::Openssh by th'timmay

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.