2008/11/1 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> Hi Dermot,
>
> The original code will upload a file but not a folder full of files. I need
> a way to ftp either:
>
> 1. ftp the whole folder with all the items inside
> 2. have perl read in all the file names and then upload all of them one by
> one.
>
> I can see the logic but i dont know how to write it?
>
> THanks a bunch!
>
> Barry

Fair enough. So either read all the files into an array before you
start your FTP transaction or use a recursive method from Net:FTP but
the latter doesn't exist within the module or the protocol as far as I
know.
http://search.cpan.org/~gbarr/libnet-1.22/Net/FTP.pm

I am not going to be able to test this from where I am writing so this
is just a guide.


my $folder_to_mirror_my_machine = "99";
opendir(DIR, $folder_to_mirror_my_machine) or die "Can't read
$folder_to_mirror_my_machine: $!\n";
my @files_to_upload = grep{! /\./ && -f
"$folder_to_mirror_my_machine/$_" } readdir(DIR);
$ftp=Net::FTP->new($host);
$ftp->login($user,$pw) or die "could not login";
$ftp->cwd($dir);
# You may choose to make the local dir at this point
# $ftp->mkdir($folder_to_mirror_my_machine);
$ftp->ascii;
foreach my $file (@files_to_upload) {
     $ftp->put($file);
}
...
...
...

You nearly had in. I think you assumed that you could copy a directory
and it's files in one hit but that not possible with Net::FTP
Goodluck.
Dp.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to