Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Mirror a local directory to an FTP server

by davis (Vicar)
on Sep 18, 2006 at 11:54 UTC ( #573531=CUFP: print w/ replies, xml ) Need Help??

This is disgusting, but it's a just a quick-n-dirty hack to upload a directory structure to a remote FTP server where the FTP server would only allow one "put" command per login session. Yes, really. Obviously there was no ssh access otherwise I would have used rsync/scp -r. Oh well.
#!/usr/bin/perl use warnings; use strict; use Net::FTP; use File::Basename; my $startdir = "somewhere"; my $ftphost = "somehost"; my $ftpuser = "someuser"; my $ftppass = "somepass"; upload_dir($startdir); sub upload_dir { my $dir = shift; foreach my $entry (<$dir/*>) { upload_dir($entry) if(-d $entry); my $ftp = Net::FTP->new($ftphost) or die "Can't connect to $ftphost: $@"; $ftp->login($ftpuser, $ftppass) or die "Can't login ", $ftp->message; my $dirname = dirname $entry; $ftp->mkdir($dirname, 1); $ftp->cwd($dirname); $ftp->put($entry); $ftp->quit; } }

Kids, you tried your hardest, and you failed miserably. The lesson is: Never try.

Comment on Mirror a local directory to an FTP server
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://573531]
Approved by Limbic~Region
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2015-11-28 15:42 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (743 votes), past polls