in reply to EXPORT and Net::Openssh
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!!
|
|---|