Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

How to fulfil the function of ftpls on windows

by Anonymous Monk
on May 30, 2002 at 10:45 UTC ( [id://170338]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am a novice at Perl,and I am doing a project FTP Search Engine on WindowsNT,but I am really swamped at work when it comes to generate a listing of files and directories in a FTP directory automatically. I tried to use ftpls but it dose not work well as I expected! Please help! Thanks advance!
  • Comment on How to fulfil the function of ftpls on windows

Replies are listed 'Best First'.
Re: How to fulfil the function of ftpls on windows
by derby (Abbot) on May 30, 2002 at 11:46 UTC
    AM, Have you looked at Net::FTP (bundled with libnet)? Give that a shot and come back, with code, if you have any problems.

    -derby

Re: How to fulfil the function of ftpls on windows
by atopolc (Pilgrim) on May 30, 2002 at 14:00 UTC
    Being that you are on NT. You might want to look into Win32::Internet.
    This module contains a nice ftp function. For your project you will want to look specifically at the list method. It would allow you to do something like this.
    @files = $FTP->List(); @textfiles = $FTP->List("*.txt"); foreach $file (@textfiles) { print "Name: ", $file, "\n"; }

    The list method also takes an optional list mode parameter in this case 2, which would give information like size, attributes,creation time and so forth.
    @files = $FTP->List("*.*", 2);
Re: How to fulfil the function of ftpls on windows
by Marza (Vicar) on May 30, 2002 at 23:40 UTC

    What are you asking for? An LS listing of files on the ftp server?

    If that is the case you will find that it depends. The mod is not complete(you will see mget is missing) and some FTP clients don't have all the commands

    Here is a snippet of old code I threw together when building an autodownloader for virus DAT files. I needed an LS of the directory since mget did not work and there were multple files to choose from:

    sub ftp_sdat { my $path = "pub/antivirus/datfiles/4.x/"; use constant HOST => 'ftp.nai.com'; use constant DIR => 'pub\antivirus\datfiles\4.x'; my $depost = "D:\\Depot\\McAfee\\updateNT\\"; my $ftp = Net::FTP->new(HOST) or die "Couln't connect: $@\n"; $ftp ->login("anonymous",'user@domain.com') or die $ftp->message; $ftp->binary or die $ftp->message; # # Since the Mget command is missing. We get a ls listing and then # look for the current SDAT file. my @dirlist = $ftp->ls("$path") or die $ftp->message; foreach my $file (@dirlist) { if ($file =~ /sdat/) { print "dat $file\n"; $ftp->get("$file") or die $ftp->message; } } $ftp->quit; return $file; }

    If this is not the case, reply back with more details....

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://170338]
Approved by moodster
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 09:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found