in reply to Howto Access Two Consecutive Hosts with Net::SFTP

Hi neversaint,

A quick look at NET::SFTP shows no automatic way to do this.
Could you not use NET::SSH::Perl to connect to host1 and the sftp the files form host1 to host2?

Hope this helps.

Martin
  • Comment on Re: Howto Access Two Consecutive Hosts with Net::SFTP

Replies are listed 'Best First'.
Re^2: Howto Access Two Consecutive Hosts with Net::SFTP
by neversaint (Deacon) on Nov 14, 2005 at 14:13 UTC
    Dear marto,
    Could you not use NET::SSH::Perl to connect to host1 and the sftp the files form host1 to host2?
    Can you give small example of how to do it? Sorry I'm really new with NET module here. I couldn't think about how to go about it. Here is what I tried to do..and lost..
    use Net::SSH::Perl; my $host = 'host1'; my $host2 = 'host2'; my $user = 'edwardwi'; my $pass1 = 'foo'; my $pass2 = 'bar'; # command to do SFTP to host2 # Doesn't seem to work... my $sftp_cmd = Net::SFTP->new($host2, "user" => $user, "password" => $pass2, "debug"=>1) || die 'cannot login $!\n'; my $ssh = Net::SSH::Perl->new($host, port => 22); $ssh->login($user, $pass); # Also how can I call "put/get" command in this context? my ($stdout,$stderr,$exit) = $ssh->cmd($sftp_cmd);
    Is there a correct way to do it?

    ---
    neversaint and everlastingly indebted.......