in reply to ftping a file from a remote server to another remote server

Welcome to the Monastery.

Firstly you've posted in the wrong section of the forum (see Where should I post X?). You should look at using the Net::FTP module. You may want to read up on FTP security if you're not already familiar with the issues involved.

  • Comment on Re: ftping a file from a remote server to another remote server

Replies are listed 'Best First'.
Re^2: ftping a file from a remote server to another remote server
by shivamem (Initiate) on Jul 20, 2011 at 05:00 UTC
    hi marto,

    Thanks for your reply,

    here is my code.

    I need a perl script or module which could ftp a file from A server to B server and from B to C server and the script should be running on A server. and there is no connection between A to C and for each server(A,B,C) user and password authentication is required. please help on it. i had writen a script on below plese look into it and help me on it. on server A some.hostA.com the below script have been writen. and trying to execute on the A server.

    #!/usr/bin/perl use Net::FTP; $ftp = Net::FTP->new("some.hostB.com", D +ebug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->login +("xxx",'xxx') or die "Cannot login ", $ftp->message; #$ftp->cwd("/pub +") # or die "Cannot change working directory ", $ftp->message; $ftp-> +put("cron/eid_inv_ftp.pl"); $newftp = Net::FTP->new("some.hostC.com", + Debug => 0) or die "Cannot connect to some.host1.name: $@"; $newftp- +>login("xxxx",'xxx') or die "Cannot login ", $newftp->message; print +$newftp->pwd(); $newftp->put($ftp->get("/export/home/xx/debugtrans.pl +")) or die "put failed ", $newftp->message; $newftp->quit; $ftp->quit +;
      You should put <code> </code> tags around your code so that formatting (like line breaks) is preserved.

      Your approach is faulty:
      $newftp->put($ftp->get("/export/home/xx/debugtrans.pl"))
      You can't do a "put" of a "get". Two steps are required. You need to connect to B, download (get) the file onto machine A (your machine). Then connect to C and upload (put) the file.

      Start with one step at a time. First get the download of the file from machine B to machine A working. Then try connecting and uploading to C.

      Read the documentation carefully about "where" the file will go..

        Hi Marshall, Thanks for your reply, Actual my requirement is there are 3 servers(A,B,C). A->B there is a network for ftping the file B->C there is a network for ftping the file A->C there is no network or firewall enabled So, A script should run on A server and ftp the file to B remote server and then the same script should run by logging into B server need to ftp the file to C which was done ftp onto B, server since there is no routing from A->C. the flow should be The script should be running only on A server A->B->C Please help me on the above query Regards, Shiva Krishna