On Thu, 2003-08-28 at 10:34, Johnson, Shaunn wrote:
> Howdy:
>
> I'm looking for information that will let me
> open an ftp connection and grep / search
> for files and then FTP them back to me.
>
> I saw something about FTP and macros, but
> the other articles about Net::FTP got me to
> believe you can do this with Perl. If so,
> is Net::FTP the route the go?
>
> Is this possible?
Of course it is! Here's a connection I use on our local network that
greps for files using the output of $ftp->ls and the grep function.
Then you throw them in a loop with $ftp->get() and your done.
Yeah, sure more error checking can be done, but this serves my purpose.
$ftp = Net::FTP->new("172.16.1.2", Debug=> 0);
$ftp->login("usr4",'cam');
$ftp->ascii;
$ftp->cwd($path);
@filelist = grep{/[e|f][d|m|v|s].ic$/} $ftp->ls($path);
foreach (@filelist) {
print "$_\n";
$ftp->get($_) or warn "Net::FTP->get: couldn't get $_";
}
#$ftp->get($file1);
#$ftp->get($file2);
$ftp->quit;
Hope this helps,
Kevin
--
K Old <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]