#!/usr/bin/perl -w use strict; use Net::FTP; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); my $home="mysite.com"; my $username="username"; my $password="password"; my $directory="data/edit"; my $filename="data.txt"; my $away="myothersite.com"; my $awayname="awayname"; my $awaypass="awaypass"; my $awaydir="data/edit"; print "Content-type: text/html\n\n"; my $ftp1 = Net::FTP->new("$home") or die "Can't connect: 1 $@\n"; $ftp1->login($username, $password) or die "Couldn't login - 1\n"; $ftp1->cwd($directory) or die "Couldn't change directory - 1\n"; my $ftp2 = Net::FTP->new("$away") or die "Can't connect: 2 $@\n"; $ftp2->login($awayname, $awaypass) or die "Couldn't login - 2\n"; $ftp2->cwd($awaydir) or die "Couldn't change away dir +ectory - 2\n"; my @lines = $ftp1->ls("/data/edit"); foreach (@lines) { $ftp1->get($filename)or die "Couldn't get $_\n"; $ftp2->put($filename) or die "Couldn't put $_\n"; print "Your file,
$_, has been successfully uploaded.\n"; } $ftp1->quit; $ftp2->quit; unlink @lines; # This should delete all the local copies of the files in @lines exit;