Hi,
I have some network equipements (extreme networks) on
which I'm able to use the Net::SCP perl module.
** I made a little test script that works
#!/usr/bin/perl
use Net::SFTP;
my $cisco = '10.1.1.1';
my $extreme = '10.2.2.2.2';
#my $host = $cisco;
my $host = $extreme;
my $user = "mikydevel";
my $password = "mypass";
my %table;
$table{debug} = 1;
$table{interactive} = 0;
$table{"user"} = $user;
$table{"password"} = $password;
use Net::SFTP;
my $sftp = Net::SFTP->new($host,%table);
$sftp->get("configuration.cfg", "CONFIG.RUN");
** I try to implement this functionality in my
existing script
I have a sub that calls the net_scp_extreme sub if the
type of connection is scp
elsif ($connexion eq 'scp')
{
my $thr = threads->new('net_scp_extreme', $ip,
$host, $pf, $device, $login, $pass, $enable);
$thr->detach();
}
and the sub looks like this, some variable such as
$host or $pf are passed to the sub just for error
information
sub net_scp_extreme
{
my ($ip, $host, $pf, $device, $login, $pass, $enable)
= @_;
my $session;
my %parametres;
my $sftp;
my %table;
$table{debug} = 1;
$table{interactive} = 0;
$table{"user"} = $login;
$table{"password"} = $pass;
my $sftp = Net::SFTP->new($ip,%table);
$sftp->get("configuration.cfg", "R02.RUN");
$nb_routeur++;
return;
}
When I run the script I have this error message
host: Remote protocol version 2.0, remote software
version 2.0.12 (non-commercial)
host: Net::SSH::Perl Version 1.30, protocol version
2.0.
' matches pattern '^2\.0\.'.2.0.12 (non-commercial)
thread failed to start: Can't locate object method
"blocking" via package "FileHandle" at
/usr/lib/perl5/site_perl/5.8.5/Net/SSH/Perl.pm line
216, <LISTE> line 1.
Segmentation fault
line 216 corresponds to the line below
defined($sock->blocking(0))
or die "Can't set socket non-blocking: $!";
<LISTE> line 1 correspond to a desciptor associated
with a file that I use for input. It contains the IP,
hostname, login, password etc
When I comment these two lines
defined($sock->blocking(0))
or die "Can't set socket non-blocking: $!";
the script goes further and segfault later
NB:
When I want to share a variable between threads I use
use threads;
use threads::shared;
my $nb_routeur : shared = 0;
and all the threads are able to increment the variable
$nb_routeur
To sum up my problem, the implementation of Net:SCP
inside threads doesn't work.
Does anybody ever had this problem ?
_____________________________________________________________________________
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr
|