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.......

In reply to Re^2: Howto Access Two Consecutive Hosts with Net::SFTP by neversaint
in thread Howto Access Two Consecutive Hosts with Net::SFTP by neversaint

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.