Paul Kraus wrote:
I am using the code below. When I run the script if I run it for just one
file then everything works fine. It asks me for my passpharase and copies
perfectly. If I uncomment both scp -> iscp statements and run the script it
asks me for the first one and then locks on the question proceed [y/N] for
the second I have to kill the cmd window to get back.

Any thoughts?


#!/usr/bin/perl


use strict;
use warnings;

use Net::SCP qw / scp iscp /;
my $leases = 'hylafax:/var/state/dhcp/dhcpd.leases';
my $access = 'hylafax:/usr/local/squid/var/logs/access.log';

my $scp = Net::SCP -> new ( 'hylafax', 'pdk' );

print "Getting Leases File\n";
$scp -> iscp ( $leases, 'scpleases.txt' );

print "Getting Access File\n";
$scp -> iscp ( $access, 'scpaccess.txt' );


What system are you running this on? What is the system you are connecting to? Can you clarify where it is hanging, is it on the proceed question for the first or second file? Is the first file being copied successfully?


I suspect it is a problem with the 'waitpid' that is being done to reap the process, that or the fact that it is using an Open3 call but doing nothing with the writer/reader pipes.

I don't normally do this, but I am tempted to say you shouldn't use the module. In general I don't like shelling out, especially when IPC is involved, and I am not sure the module does a good enough job handling the possibilities of deadlock with respect to Open3 (which is maybe what you are seeing). You also mention entering a password which it says not to do, I am not quite sure how that is even working and this might also be the problem, as the Perl program isn't prompting for one, it is the scp doing that, but if the scp's pipes are being handled by the Open3 then the password is never getting there, which is curious to say the least. But these issues aside, the fact that there is a parameter listed in the POD for 'interactive' mode which is passed through to set $self->{'interactive'} in the constructor but then it is $self->{'interact'} that is actually called for in the source of scp indicates a general lack of attention to detail within what is relatively simple source, the fact that it could be misdocumented really scares me...

However that doesn't help you much I suspect. Two options appear to me, if you don't mind the dependency hell of Net::SSH::Perl, and if all out speed isn't an issue, you might check out Net::SFTP. I have had very good luck with it, 1 issue aside (which has to do with memory leaking in Math::PARI for long running (aka 3+ hours) scripts). Alternatively you could roll your own 'scp' wrapper using Expect (which I seldom advocate but haven't seen a better option for calling scp yet).

In any case, if you are not using key based authentication and intend to run this interactively why both with the Perl script at all?

http://danconia.org


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to