
cuboidgraphix
User
Dec 30, 2008, 9:45 AM
Post #12 of 22
(16193 views)
|
Re: [FishMonger] FTP to multiple directories and finding specific files.
[In reply to]
|
Can't Post
|
|
Hi again Fishmonger, I tried the code you last wrote and it worked clean for the most part. But I still get the same error I get with my script.
Net::FTP=GLOB(0x9d6210)>>> user USERNAME Net::FTP=GLOB(0x9d6210)<<< 331 Password required. Net::FTP=GLOB(0x9d6210)>>> PASS .... Net::FTP=GLOB(0x9d6210)<<< 230 User logged in, proceed Net::FTP=GLOB(0x9d6210)>>> TYPE I Net::FTP=GLOB(0x9d6210)<<< 200 Command okay. changing cwd to D010AMAB Net::FTP=GLOB(0x9d6210)>>> CWD /D010AMAB Net::FTP=GLOB(0x9d6210)<<< 200 Directory changed. Directory changed. Net::FTP=GLOB(0x9d6210)>>> PORT 10,24,1,51,85,224 Net::FTP=GLOB(0x9d6210)<<< 200 PORT Command okay Net::FTP=GLOB(0x9d6210)>>> NLST Net::FTP=GLOB(0x9d6210)<<< 503 TYPE must be ASCII changing cwd to D000AMAA Net::FTP=GLOB(0x9d6210)>>> CWD /D000AMAA Net::FTP=GLOB(0x9d6210)<<< 200 Directory changed. Directory changed. It gives that error for every directory. < 503 TYPE must be ASCII. Well I'm glad I've learned plenty from your help, but it sucks I can't get this script to work. I'll take your advice and look at the SFTP option. I don't know how long it will take me to write it, but I hope you're still around to guide me. For all the rest of the forum, I hope this script helps them if they want it to work in ASCII code.
#!/usr/bin/perl use strict; use warnings; use Net::FTP; use POSIX qw/strftime/; my $Yday = strftime("R%y%m%d", localtime(time - 86400)); my @myDIR =('D010AMAB', 'D000AMAA', 'D010AMA9', 'D000AMA8', 'D010AMA5', 'D000AMA6', 'D010AMA7', 'D000AMA4', 'D010AMA3', 'D000AMA2', 'D010AMA1', 'D000AMA0' ); my $ftp = Net::FTP->new("HOST", Debug => 1) or die "Failed to connect to FTP server "; print $ftp->message(), "\n"; $ftp->login("USER",'PASS') or die "Failed to login to FTP server ", print $ftp->message(); #$ftp->binary or warn "Unable to switch to binary mode "; foreach my $DIR(@myDIR){ print "changing cwd to $DIR\n"; $ftp->cwd("/$DIR") or warn "Failed to cd to /$DIR ", print $ftp->message() and next; print $ftp->message(), "\n"; my @file = grep { /^([^.].*)?$Yday/ } $ftp->ls(); foreach my $file(@file){ print "retriving file '$file'\n"; $ftp->get($file) or warn "Failed to retrieve '$file' ", print $ftp->message() and next; print $ftp->message(), "\n"; } }
|