swaroop has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,
Please check the below code. Its hanging. I want to copy the remote files to local server "servera" with the login user "swaroop".

thanks,
Swaroop


****************************
use IO::Pty; use Net::SCP::Expect; my $scpe = Net::SCP::Expect->new; $scpe->host("servera"); $scpe->login("swaroop","xxxxx"); $scpe->auto_yes("1"); $scpe->scp('servera:/tmp/testfile','testfile');
*****************************

Replies are listed 'Best First'.
Re: Net::SCP::Expect problem
by phignuton (Novice) on May 06, 2005 at 15:32 UTC
    <delurk>
    
    Have you ssh'd to the box before? It might be hanging on the key-cache query (yes/no)...

    Also, if you have access to the box, you might think about using keyfiles to streamline the process and it your password wouldn't have to be in the script...

    I've always had better luck with system calls to scp using null-passphrase keys myself...

    </delurk>
    
      I have set auto_yes = 1. So, I don't think its really the problem.

      - Swaroop
Re: Net::SCP::Expect problem
by danielcid (Scribe) on May 06, 2005 at 18:19 UTC
    Hi,
    Looks like you inverted the options on "$scpe->scp(..)". Try the following:
    use strict; use warnings; use IO::Pty; use Net::SCP::Expect; my $scpe = Net::SCP::Expect->new; $scpe->host("servera"); $scpe->login("swaroop","xxxxx"); $scpe->auto_yes("1"); $scpe->scp('testfile','servera:/tmp/testfile');

    If this doesn't work. Check if "testfile" exists. Or specify the full path of it (like /home/xx/testfile).
    Also check if "servera" is being resolved correctly (or use its IP Address instead).

    If none of this work, you should get an error message from this module explaining (enable debug)...

    -DCB
      How to enable debug ?? its really buggin me re.

      - Swaroop
      I too have same problem. Got the error as "Problem performing scp: yes/no at gg.pl"