in reply to SSH connection with module
You end up creating two completely separate Expect objects.
You should create a cisco::new() method that creates an object (see 'perldoc perltoot') - this method should look something like this:
Once you get an object back from new(), you need to call login_auth like this:sub new{ my ($class, $logname) = @_; $logname or die "NO log file name specified"; my $self = bless {}, $class; # Creating an empty instance $self->{EXP} = Expect::->new(); # Now has an EXP attribute open $self->{LOGFH}, ">>", $logname or die "Could not append to $l +ogname : $!"; return $self; }
Of course, you will need to modify login_auth() to accept a parameter, preferably named $self.my $cisco = cisco::->new(); $cisco->login_auth();
Update: Added LOG to new() method.
So happy journey into the world of OO programming!
If you run into concept issues with how or why things are done is a certain way, be sure to post specific questions here, for assistance.
What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
-Larry Wall, 1992
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: SSH connection with module
by MysticRyuujin (Novice) on Mar 10, 2014 at 01:40 UTC | |
by NetWallah (Canon) on Mar 10, 2014 at 03:39 UTC | |
by Anonymous Monk on Mar 10, 2014 at 04:34 UTC |