You can use Net::FTP module. Here is the subroutine in my Perl class:
use Net::FTP;
use Debug::EchoMessage;
=head3 ftp_dir($nf, $ldir, $rdir, $opt)
Input variables:
$nf - a Net::FTP object.
$ldir - local directory
$rdir - remote directory
$opt - hash array ref containing parameters:
files - file name pattern
Variables used or routines called:
Debug::EchoMessage
echoMSG
How to use:
my $nf = Net::FTP->new("some.host.name", Debug => 0)
or die "Cannot connect to some.host.name: $@";
$nf->login("anonymous",'-anonymous@')
or die "Cannot login ", $ftp->message;
my $ar = $self->ftp_dir($nf,'/mylocal/dir', '/my/remotedir');
Return: $ar contain a list of files being transferred.
=cut
sub ftp_dir {
my $self = shift;
my($obj,$ldr, $rdr, $ar) = @_;
croak "No Net::FTP object is specified.\n" if ! $obj;
croak "No local directory is specified.\n" if ! $ldr;
croak "No remote directory is specified.\n" if ! $rdr;
$self->echoMSG(" Transferring files...", 1);
$self->echoMSG(" From $ldr\n To $rdr", 2);
opendir LDR, $ldr or croak "ERR: could not list in $ldr: $!\n";
my @fns = ();
if ($ar && exists ${$ar}{files}) {
@fns = grep /${$ar}{files}/, readdir LDR;
} else {
@fns = grep !/^\.\.?$/, readdir LDR;
}
closedir LDR;
# $obj->cwd($ldr) or croak "ERR: could not change dir to $ldr:
$!\n";
$obj->cwd($rdr) or
$obj->mkdir($rdr,1) or
croak "ERR: could not make dir $rdr: $!\n";
foreach my $f (@fns) {
$self->echoMSG(" : $f", 3);
$obj->put("$ldr/$f", "$rdr/$f");
}
$obj->quit;
return @fns;
}
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Krishna, Hari
Sent: Thursday, June 23, 2005 2:48 PM
To: Perl-Win32-Users Mailing List
Subject: FTP Help
How can we FTP directories and files in those directories.
I ahev a directory A inside which I have several and files and Directory
B
which has more files and directories.
I wld want to be able to FTP the entire Directory A so it can copy it to
the
destination.
I need to FTP because the system is a remote system and the only way is
to
FTP.
I am looking on Google to see if there are any commands or programs
available taht I can use to automate the process.
Thanks,
Hari
CONFIDENTIALITY NOTICE:
This e-mail message, including all attachments, is for the sole use of
the
intended recipient(s) and may contain confidential and privileged
information. You may NOT use, disclose, copy or disseminate this
information. If you are not the intended recipient, please contact the
sender by reply e-mail immediately. Please destroy all copies of the
original message and all attachments. Your cooperation is greatly
appreciated.
Columbus Regional Hospital
2400 East 17th Street
Columbus, Indiana 47201
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs