Home > Archive > PERL Beginners > May 2007 > Upload a directory to remote FTP server
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Upload a directory to remote FTP server
|
|
| Shu Cho 2007-05-24, 4:00 am |
| Hi list,
I want to upload a directory to a remote FTP server, is there any nice
solution? Here is my script:
#!/usr/bin/perl
use Net::FTP;
use File::Find;
$ftp = Net::FTP->new("host", Port => 1234);
$ftp->login("usr", "passwd");
sub upload_file {
$ftp->mkdir($File::Find::name, 1) if -d;
$ftp->cwd($File::Find::name);
$ftp->put($File::Find::name) if -f;
}
$dir_to_upload = qw(/data);
find(\&upload_file, @dir_to_upload);
$ftp->quit();
It seems my code is ugly:( Can you guys give me some hints?
TIA
--
Shu Cho <onionlab@gmail.com>
| |
| yaron@kahanovitch.com 2007-05-24, 9:58 pm |
| Hi,
Did you try to use Net::FTP::Recursive (http://search.cpan.org/~jdlee/Net-F...00/Recursive.pm)
It seems to fit to your task.
Yaron Kahanovitch
----- Original Message -----
From: "Shu Cho" <onionlab@gmail.com>
To: beginners@perl.org
Sent: Thursday, May 24, 2007 10:26:00 AM (GMT+0200) Auto-Detected
Subject: Upload a directory to remote FTP server
Hi list,
I want to upload a directory to a remote FTP server, is there any nice
solution? Here is my script:
#!/usr/bin/perl
use Net::FTP;
use File::Find;
$ftp = Net::FTP->new("host", Port => 1234);
$ftp->login("usr", "passwd");
sub upload_file {
$ftp->mkdir($File::Find::name, 1) if -d;
$ftp->cwd($File::Find::name);
$ftp->put($File::Find::name) if -f;
}
$dir_to_upload = qw(/data);
find(\&upload_file, @dir_to_upload);
$ftp->quit();
It seems my code is ugly:( Can you guys give me some hints?
TIA
--
Shu Cho <onionlab@gmail.com>
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
|
|
|
|
|