Click here to get back home

problems using Net::SSH::Perl in a while loop

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
problems using Net::SSH::Perl in a while loop Thonas Siegenthaler 04-29-2005
Get Chitika Premium
Posted by Thonas Siegenthaler on April 29, 2005, 10:09 am
Please log in for more thread options


Hi Folks

I want to usw Net:SSH::Perl to automatically run some commands on several
hosts.
All the hostnames are stored in a database.

I decided to use Net::SSH::Perl because I can configure everything I need.
The auth is
done by a SSH-Key (RSA). Unfortunately not all of the hosts in the DB have
the SSH
Key stored in their ~/.ssh/authorized_keys. When I try to connect to one of
these
hosts using SSH2, my script dies because of a Carp::croak() call in the
Net::SSH::Perl::AuthMgr module (line 142).

Is there a way to turn off this "die" and just get a error-message instead?
If a hosts doesn't
have this ssh-key, I don't want to abort my script, I wnat to continue with
the next hostname
instead.

Thanks in advance
--Thomas




Posted by Mark Clements on April 29, 2005, 10:34 am
Please log in for more thread options


Thonas Siegenthaler wrote:
> I want to usw Net:SSH::Perl to automatically run some commands on several
> hosts.
> All the hostnames are stored in a database.
>
> I decided to use Net::SSH::Perl because I can configure everything I need.
> The auth is
> done by a SSH-Key (RSA). Unfortunately not all of the hosts in the DB have
> the SSH
> Key stored in their ~/.ssh/authorized_keys. When I try to connect to one of
> these
> hosts using SSH2, my script dies because of a Carp::croak() call in the
> Net::SSH::Perl::AuthMgr module (line 142).
>
> Is there a way to turn off this "die" and just get a error-message instead?
> If a hosts doesn't
> have this ssh-key, I don't want to abort my script, I wnat to continue with
> the next hostname
> instead.

I'm not familiar with this module, but you can normally wrap die calls
with eval:

eval {
        print "enter evaln";
        die "die here";
        print "end evaln";
};
if($@){
        print "trapped error - $@";
        # handle error
}
print "script continues...n";

perldoc -f eval

Mark


Similar ThreadsPosted
Re: Re: problems using Net::SSH::Perl in a while loop April 29, 2005, 1:45 pm
Problems with CGI::Session in Perl August 8, 2005, 11:25 am
perl SAP RFC SDK make problems in fedora December 2, 2005, 2:47 am
Problems finding gd.pm in perl 5.8.6 using linux February 16, 2006, 4:59 pm
Problems with Apache 2.0, mod_perl2 and perl May 31, 2006, 3:48 pm
Problems using GD.pm January 8, 2005, 8:05 pm
Problems when using Net::MSN 1.022 May 4, 2005, 1:20 pm
LWP problems July 11, 2005, 3:50 pm
PPM Problems on Win.XP November 5, 2007, 4:26 pm
LWP Problems (Authentication?) September 5, 2004, 7:12 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap