Re: [Ssh-sftp-perl-users] net::ssh::perl error handling
Brought to you by:
dbrobins
From: Dave R. <au...@ur...> - 2003-12-03 15:54:55
|
On Tue, 2 Dec 2003, fred stiler wrote: > 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"; Try this: eval { $ssh = Net::SSH::Perl->new($host) }; die $@ if $@; I can't just go and change the module not to die, because that would break backwards compatibility. -dave /*======================= House Absolute Consulting www.houseabsolute.com =======================*/ |