On Tue, Mar 12, 2002 at 10:07:20PM +1100, Bernhard L?der wrote:
> Ok, that works for known files, but what if I have to upload new directories
> & folders with files in them?
> Is there a recursive feature in ftp?

Unfortunately not. I have included a perl script that I wrote last week when suddenly 
my shell access was turned off by my web provider. This does not create any 
directories but its easy to add to this script if needed.  It uses ftp rather than 
having to worry about Net::ftp in Perl. Was a quick 20 min hack.
Note that you can use a .netrc file but it probably safer not to. If it is not there 
the ftp will just ask for the passwd.

#!/usr/bin/perl -w

use strict;

my $localDir    = "/home/mikel/public_html/speleonics/"; 
my $remoteDir   = "/home/mikel/public_html/";

my $i;
my @changedFiles;
my $ftpuploadFile = "/tmp/ftpupload.myisp";

print "\n";
print "****************************\n";
print "*** FTP upload to My ISP ***\n";
print "****************************\n\n";

print "FTP transfer uses file .netrc to connect to ISP.\n";
print "Local directory to upload files FROM will be: $localDir\n";
print "Remote directory to upload files TO  will be: $remoteDir\n";

@changedFiles = `find $localDir -type f -mtime -7`;


########################
# Write the ftp script
########################

open(FILE, ">$ftpuploadFile") || die "Can't open file: $!";

print FILE "open tazieff\n";
print FILE "prompt\n";
print FILE "lcd $localDir\n";
print FILE "cd $remoteDir\n";

print "\nAdding files to ftp script to upload...\n";
foreach $i (@changedFiles)
{
        $i =~ s/$localDir//;
        print "file: $i";
        print FILE "put $i";
}

print FILE "close\n";
print FILE "bye\n";

close (FILE);

print "\nRunning ftp upload now... (watch for errors below here)\n";
print `ftp < $ftpuploadFile`;

print "\nRemember to delete the file $ftpuploadFile when finished.\n";



-- 
Hunt and kill the dangerous animal for my email.     [EMAIL PROTECTED]


UTS CRICOS Provider Code:  00099F

DISCLAIMER
=====================================================================
This email message and any accompanying attachments may contain
confidential information.  If you are not the intended recipient, do not
read, use, disseminate, distribute or copy this message or attachments.
If you have received this message in error, please notify the sender
immediately and delete this message. Any views expressed in this message
are those of the individual sender, except where the sender expressly,
and with authority, states them to be the views the University of
Technology Sydney. Before opening any attachments, please check them for
viruses and defects.
=====================================================================


-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to