RE: [Ssh-sftp-perl-users] How to stop "error conditions" from terminating a script.
Brought to you by:
dbrobins
|
From: Mark A. <mar...@sh...> - 2005-05-31 14:30:20
|
I don't know what your attempted eval block looked like, but I don't
know why this wouldn't work...
=20
$args{user} =3D $account;
$args{password} =3D $password;
my $sftp;
eval { =20
$sftp =3D Net::SFTP->new($host,%args);
};
if ( $@ ) {
warn "sftp error: $@\n";
# get next host
}
if ( $sftp ) {
...
} else {
warn "$sftp was false.\n";
# get next host
}
-----Original Message-----
From: ssh...@li...
[mailto:ssh...@li...] On Behalf Of
Jim Lane
Sent: Tuesday, May 31, 2005 7:09 AM
To: ssh...@li...
Subject: [Ssh-sftp-perl-users] How to stop "error conditions" from
terminating a script.
Hi, All
I have an application that uses a table of hostnames, accounts and
passwords to copy data from a set of remote servers using either FTP or
SFTP as the case may be. I'm trying to write a check script that will
use this table and determine whether the hosts can be contacted and if
the file is available. I'm running into problems with Net::SFTP because
some conditions (e.g. Expired password) are treated as errors and the
script terminates at that point. I'd like to be able to trap and note
the error and continue on.
My logic looks like this:
$args{user} =3D $account;
$args{password} =3D $password;
if ($sftp =3D Net::SFTP->new($host,%args)) {
If for any reason the Net::SFTP->new doesn't work the whole script craps
out with messages of the form:
Connection closed at /home/jlane/bin/check line 41
I've seen earlier posts on this list about wrapping an eval around code
to deal with errors but that doesn't seem to work for me.
HELP! =20
Jim Lane =20
Capacity Planner =20
Rogers Shared Operations =20
(905)-513-3164 =20
FAX (905)-513-5012 =20
Jim...@rc... =20
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit =
http://developer.yahoo.net/?fr=3Dfad-ysdn-ostg-q22005
_______________________________________________
Ssh-sftp-perl-users mailing list
Ssh...@li...
https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users
|