use Net::FTP; # Create connections to both remote servers... $ftpf = Net::FTP->new('unix system') or die "Can't connect to 'from': $!"; $ftpd = Net::FTP->new('windows system') or die "Can't connect to 'dest': $!"; # ...and login to them. $ftpf->login('anonymous') or die "Can't login to 'from'"; $ftpd->login('anonymous') or die "Can't login to 'dest'"; # Place both servers into the correct transfer mode. # In this case I'm using ASCII. $ftpf->ascii() && $ftpd->ascii() or die "Can't set ASCII mode: $!"; # Send the PASV command to the destination server. # This returns a port address. $port = $ftpd->pasv or die "Can't put FTP host in passive mode: $!"; print $port; # Send the port address to the source server so it # knows where to send the data. $ftpf->port($port) or die "Error sending port: $!"; # Send the RETR and STOU commands to the servers $rfile = '/pub/swdistrib/conf/os.conf'; $ftpf->retr($rfile) or $ftpf->ok or die "Can't retrieve '$rfile': $!"; $sfile = '/swdistrib/os.conf'; $ftpd->stou($sfile) or die "Can't store '$sfile': $!"; # Wait for the transfer to complete $ftpd->pasv_wait($ftpf) or die "Transfer failed: $!"; $ftpd->close() && $ftpf->close() or die "Can't close connections: $!"; $ftpf->quit() && $ftpd->quit() or die "Can't quit ftp connections: $!";