On Wed, Mar 26, 2008 at 3:49 PM, Siegfried Heintze (Aditi) <[EMAIL PROTECTED]> wrote: > I'm using perl 5.8.8 on cygwin/windows 2003 server. > > This worked (but it was sooooo tedious!): > $ perl -MNet::FTP -e '$ftp =Net::FTP->new("mediaftp.wiley.com", Debug=>0) or > die "cannot connect"; $ftp->login("download","download") or die "cannot > login"; $ftp->cwd("/product_ancillary/76/04701913/DOWNLOAD/") or die "cannot > cd"; for (3..5) { print "getting $_\n" ; $ftp->get("ch". > sprintf("%-2.2d",$_). " CodeSample.zip") or die "cannot get" ; } '; > > Questions: > > 1. Is there an easier way?
On Linux systems, yes. Use wget or curl. > > 2. More specifically: Are there some perl modules that will parse the > string ftp://download:[EMAIL > PROTECTED]/product_ancillary/76/04701913/DOWNLOAD/Ch05%20CodeSample.zip and > download the file with one or two function calls instead of what I did above? Yes, IO::All and IO::All::FTP perl -MIO::All -e 'io("ftp://mediaftp.wiley.com/product_ancillary/76/04701913/DOWNLOAD/Ch05%20CodeSample.zip")->user('download')->password('download') > io("ch05.zip")' > > 3. I tried calling mget but there was no such function. How could I > wild card and get all the zip files in that directory? I was looking at > http://search.cpan.org/~jdlee/Net-FTP-Recursive-2.02/Recursive.pm and > wondering if this would solve my problem. Can someone help me modify my > fragment above so it recursively fetches the entire directory? I was not sure > how to pass that function pointer in the example in the documentation. get an ls of the remote directory and filter the results. #warning untested code typed from memory $sftp->get($_) for grep { /\.zip$/ } $sftp->ls; > > 4. Is perl the best way to do this? Would it be easier in some other > language/library like bash or python or ruby? If you are trying to do it from the command line then Perl is not the best way. A utility like wget or curl is much better. > Thanks! > Siegfried > -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/