#!/usr/bin/perl use Net::SSH::Perl; use threads; $filepath="/tmp/Perl/host.conf"; if(open(FILE, $filepath)) { $inputline=; while($inputline ne "") { chomp($inputline); if($inputline !~ /#/) { if( @array = split(/:/,$inputline) ) { $host = $array[1]; $user = $array[2]; $pass = $array[3]; print "\n\n\n ------ CHECK1 $user $host $pass \n\n\n\n\n "; push @threads, threads->create(\&method, $host, $user, $pass); } #if2 } #if1 $inputline=; } #while while ( my $thread = shift @threads ) { $thread->join ; print " Thread [ $host ] Ending ... \n"; } } else { die " File doesn't exists " } sub method { my($hst,$usr,$pas)=(shift,shift,shift); &thrds($hst, $usr, $pas); } sub thrds { my($h,$u,$p)=(shift,shift,shift); $ssh = Net::SSH::Perl->new($h,debug=>'true'); $ssh->login($u,$p); my($stdout, $stderr, $exit) = $ssh->cmd('hostname'); my($stdout, $stderr, $exit) = $ssh->cmd('ls -l'); print $stdout; $ssh->close(); }