Hi,


I need to move a file from server 2 to server 3, but both FTP and SSH should get initiated from server 1.

i.e
S1 (SSH)-> S2 (FTP)-> S3
file needs to be moved from S2 to S3. but the script running in S1. manually I am able to do it but through perl Net:FTP it is establishing session from server 1 instead of server 2
my code:
#!/usr/bin/perl -w use Net::FTP; use Net::SSH::Perl; my($host,$user,$pass) = ("Server2","user_name","password"); my $cmd = "whoami"; my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd($cmd); my $ftp = $ssh->cmd(Net::FTP->new("Server3", Debug => 0) or die "Canno +t connect to Server3 $@"); $ssh->cmd($ftp->login("user_name",'password') or die "Cannot login ", +$ftp->message); $ssh->cmd($ftp->cwd("/home/tmp") or die "Cannot change working directo +ry ", $ftp->message); $ssh->cmd($ftp->put("file_in_server2") or die "get failed ", $ftp->mes +sage); $ssh->cmd($ftp->quit);

In reply to how to ftp files from a remote server 1 to server 2? by kpofcochin

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.