sqspat has asked for the wisdom of the Perl Monks concerning the following question:
package Routines; use strict; use warnings; use Net::SSH::Expect; use Expect; use Carp; use IO::Pty; use HTTP::Request; use LWP::UserAgent; BEGIN { use Exporter(); use vars qw ($VERSION @ISA @EXPORT); $VERSION=1.00; @EXPORT = qw(%args &clear_config &load_config &show_config $c +ommand_showconfig); @ISA = qw(Exporter); } ###### show config #### sub show_config { my $ssh2 = Net::SSH::Expect->new ( host => "item201", user => 'root', password => 'admin', raw_pty => 1, timeout => 1 ); my $login_output2 = $ssh2->login(); if ($login_output2 !~ /Blah/) { die "Login has failed. Login output was $login_output2"; } $ssh2->exec("stty raw -echo"); my $command_suconfig = $ssh2->exec('su config'); sleep(2); my $command_showconfig = $ssh2->exec('show config'); print "\n############ SHOW CONFIG ###########\n"; print "\n$command_showconfig\n"; #Issue the commands from the command file } SECTION of SCRIPT USING MODULE (The function, &show_config works) #!/usr/bin/perl #$Expect::Exp_Internal = 1; #$Expect::Debug = 1; #use strict; #use warnings; #use diagnostics; use Routines; use Net::SSH::Expect; use Expect; &show_config; @CONFIG=undef(); push (@CONFIG,$command_showconfig; print "$command_showconfig\n"; print @CONFIG; # END OF CODE SEGMENT
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: cannot export from Module
by ELISHEVA (Prior) on Aug 13, 2009 at 16:46 UTC | |
|
Re: cannot export from Module
by Marshall (Canon) on Aug 14, 2009 at 16:29 UTC |