summaryrefslogtreecommitdiff
path: root/asp-ls
blob: c2a109fd38c5b38c21bd6cd7a4af43624d94e294 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/perl -w
# Usage: asp-ls PATH

use strict;

use Net::FTP;

my $server = "ftp.ncbi.nlm.nih.gov";
my $dir    = shift;
my $ftp    = new Net::FTP($server, Passive => 1)
  or die "Unable to connect to FTP server: $!";

$ftp->login or die "Unable to log in to FTP server";
$ftp->cwd($dir) or die "Unable to change to $dir";
my $contents = $ftp->dir;
die "Unable to list contents" unless defined $contents;

for (@$contents) {
    if (/^-.*?(\S*)$/) {
        print "$1\n";
    } elsif (/^d.*?(\S*)$/) {
        print "$1/\n";
    } elsif (/^l.*?(\S*) -> \S*$/) {
        print "$1@\n";
    }
}