i humbly submit my request for a nugget of wisdom o wise monks.
i'm trying to export some variables from a module into another, and that seems to be working as expected, however, net::openssh fails to establish a connection using the imported ones. if i declare the variables locally, everything works fine.
creds.pm
#!/usr/local/perl
package Creds;
use warnings;
use strict;
require Exporter;
our @ISA = 'Exporter';
our @EXPORT_OK = qw($user $pass $enpass);
our $user = '....';
our $pass = '....';
our $enpass = '....';
myssh.pl
#! /usr/bin/perl
use strict;
use warnings;
use Net::OpenSSH;
use Expect;
use IO::Stty;
use Creds qw($user $pass $enpass);
my $host = $ARGV[0];
my $timeout = 5;
my $ssh = Net::OpenSSH->new("$user:$pass\@$host", timeout => 10);
$ssh->error and die "unable to connect to host: ". $ssh->error;
my ($pty, $pid) = $ssh->open2pty();
my $expect = Expect->init($pty);
$expect->expect($timeout,
[
'>' =>
sub {
$expect->send('enable');
$expect->send("\r");
$expect->expect('Password:');
$expect->send($enpass);
$expect->send("\r") ;
}
],
[
'#'
],
);
$expect->interact();
i just keep getting timeout error (unable to connect to host: unable to establish master SSH connection: login timeout at).
any insight is greatly appreciated.