As I've already reported in Bug #16629, I'm quite unhappy
with the missing/incomplete error handling and false exit
codes. Studying the Foreign.pm you see that these exit codes
do NOT come from the ssh binary but from
<code>Carp::croak()</code><br>
Some situations where I expect a useful error
handling:<br>
1. hostname cannot be resolved<br>
2. no ssh-daemon running on host<br>
3. wrong username/password<br>
4. rejected public key<br>
5. every open/close/chmod/binmode/... operation<br>
6. maybe some more<br>
<br>
3. can be fixed by ssh_config-parameters:<br>
Instead of using password challange, use a public key with
an empty passphrase or a ssh-agent instead and add the
following configs to the constructor:
<code>"-oPreferredAuthentications=publickey&quo
t;,"-oPasswordAuthentication=no","-oBatchM
ode=yes"</code>
<br>
To fix the other points, the code of Foreign.pm must be
changed:<br>
In general: do NOT use Carp::croak but set
<code>$sftp->warn(...)</code> and return
undef<br>
After calling open2() in sub new(), check to see if the
forked process is still running and not in defunct state.
Sleep one second before doing so. The open2-call itself
should be surrounded by eval{} to suppress its
errors.<br>
Think about replacing open2 with open3. open3 is cappable of
returning STDERR.<br>
<br>
I hacked Foreign.pm with the mentioned improvements (really,
it is a hack...) and yes, it works for me. I'm sure that
other users will profit from the changes. I used version
0.57, but 0.60 (and the latest dev-codes) do not work
different.<br>
If you're interested in, please leave me a message and I
will send you the code (it's not enough room to paste it in
here).
<br>
Thanks
To write a respons, access
http://ww
w.cpanforum.com/response_form/2556
To see the full thread, access
http://www.cpan
forum.com/threads/2556
--
You are getting this messages from www.cpanforum.com
To change your subscription information visit http://www.cpanforum.
com/mypan/
|