Ask a Question related to PERL Modules, Design and Development.
-
NightTwix #1
net::ssh::perl error handling
Hi
im working on a script that uses Net::SSH::Perl
The problem is that i dont know how to handle errors properly.
When the script tries to connect to a host that has no sshd running or
is completly down
then the script exits with a error like:
Can't connect to x.x.x.x, port 22: Connection timed out at
/usr/lib/perl5/site_perl/5.8.0/Net/SSH/Perl.pm line 206.
but it would be much nicer if the error would be stored in a var and
the script continues.
Or at least it should die with a proper message.
i tried something like:
$ssh = Net::SSH::Perl->new($host) || die "error connecting to $host";
but had no success :/
any help is welcome
twix
--
[url]http://www.tuxhilfe.de.vu[/url]
NightTwix Guest
-
Error handling
In you provide labels or line numbers in your code, you can use ERL to get the most recent label/line number. Using line numbers does slow down... -
CF Error Handling
I currently have no error handling with the website I am working with. I want to start integrating it in. The error I am most concerned about is... -
better error handling
Stijn Goris wrote: if you print out the contents of $uploaddir.$_FILES you'll find that it's not what you expected, I think. -
Error handling and custom error messages
How can I get more informations about last error? I get the last error number with @@ERROR, but I don't know what is the source of error. For... -
Error handling in SQL
Hi. I came across following stored procedure. CREATE PROCEDURE . @iId int, @iErrorCode int OUTPUT AS -
HEKR #2
Re: net::ssh::perl error handling
[email]freestyler@6pack.de[/email] (NightTwix) wrote in message news:<4ec94413.0311301607.1af88fc4@posting.google. com>...
I don't know the module exactly but it's generally a good idea not to> Hi
>
> im working on a script that uses Net::SSH::Perl
> The problem is that i dont know how to handle errors properly.
> When the script tries to connect to a host that has no sshd running or
> is completly down
> then the script exits with a error like:
>
> Can't connect to x.x.x.x, port 22: Connection timed out at
> /usr/lib/perl5/site_perl/5.8.0/Net/SSH/Perl.pm line 206.
>
> but it would be much nicer if the error would be stored in a var and
> the script continues.
> Or at least it should die with a proper message.
> i tried something like:
>
> $ssh = Net::SSH::Perl->new($host) || die "error connecting to $host";
>
> but had no success :/
>
> any help is welcome
>
> twix
die if you don't want to :-) Try this:
--- SNIP ---
$ssh = Net::SSH::Perl->new($host);
if( ! $ssh )
{
do_some_error_handling...
}
--- SNIP ---
If this does not work (i.e. the Net::SSH::Perl raises an exception you
should catch it using eval:
--- SNIP ---
eval "$ssh = Net::SSH::Perl->new($host);";
if( $@ )
{
do_some_error_handling...
}
--- SNIP ---
Helge
HEKR Guest
-
Keegan Holley #3
Re: net::ssh::perl error handling
/usr/lib/perl5/site_perl/5.8.0/Net/SSH/Perl.pm line 206.
Can't tell how old this thread is but the problem is that there is a die in the module itself as seen in the error message. I'm still pretty much a beginner but the two solutions presented didn't work. I've resulted to using ping to verify that I can reach whatever it is I'm connecting to before passing the IP to net::SSH:perl. Cumbersome but it prevents the crash.
Junior Member
- Join Date
- Aug 2011
- Posts
- 1



Reply With Quote

