Article 9818 of comp.lang.perl:
Xref: feenix.metronet.com comp.lang.perl:9818 alt.sources:2646
Path: feenix.metronet.com!internet.spss.com!insosf1.infonet.net!news-feed-1.peachnet.edu!news-feed-2.peachnet.edu!emory!europa.eng.gtefsd.com!howland.reston.ans.net!news.intercon.com!udel!gramps.itd.com!ma.itd.com!jblaine
From:
[email protected] (Jeff Blaine)
Newsgroups: comp.lang.perl,alt.sources
Subject: iarchie: An interactive backend to archie, frontend to NcFTP
Date: 16 Jan 1994 07:24:28 GMT
Organization: Space Remote Sensing Center
Lines: 104
Distribution: world
Message-ID: <
[email protected]>
NNTP-Posting-Host: ma.itd.com
This is a backend to archie (slash) frontend to NcFTP.
You must have archie and NcFTP to make use of this script (as well as perl).
Let me know what you think.
#!/usr/local/bin/perl
#
# Interactive Archie for terminals.
# Jeff Blaine, 1994,
[email protected]
#
# READ THIS:
# This is NOT an archie implementation. You must have archie
# installed as well as NcFTP to use this perl code to interactively
# (ahem) search for and retrieve files.
#
# You can get NcFTP from cse.unl.edu:/pub/mgleason/ncftp
# You can get archie from nic.sura.net:/pub/archie/clients
#
# iarchie should be called exactly like your copy of archie (same
# args you always use). Example usage:
#
# prompt% iarchie -h archie.ans.net filename.tar.Z
#
# Please see the end of this Perl script for more commented information.
#
# INSTALLER: Define NCFTP to point to your copy of NcFTP. That's all.
$NCFTP = '/usr/code/sun/bin/ncftp';
$VERSION = '1.0';
$ia_tmp = "iarchie.tmp";
$0 = iarchie;
$| = 1; # Flush stdout on all writes.
if ($ARGV[0] eq "") {
&usage;
exit (1);
}
print "Connecting to archie server and retrieving information...\n";
print "";
unlink ("$ia_tmp"); # Remove any old temp file.
system ("archie -l @ARGV > $ia_tmp"); # Call archie.
&parse_archie; # Parse output from archie.
&print15; # Menu and select.
unlink ("$ia_tmp"); # Remove temp file.
sub usage {
print "Usage:\n";
print " $0 uses all of the same options as the c-archie package.\n";
print " Type 'man archie' to see those options.\n";
}
sub parse_archie {
open (INFILE, "$ia_tmp") || die "Couldn't open $ia_tmp\n";
while (<INFILE>) {
if ($_ ne '\n') {
@curr = split;
$ncftp_line = $curr[2] . ":" . $curr[3];
$ncftp_line = "$ncftp_line\n";
push (@ncftp_lines, $ncftp_line);
}
}
close (INFILE);
print "\n";
}
sub print15 {
$num = 0;
while ($num != 15) {
print "$num ) ", $ncftp_lines[$num];
$num++;
}
print "\n";
print "Enter a number or 'q' to quit: ";
$ch = getc;
if ($ch eq "q") {
exit (0);
} elsif ($ch =~ /[0-15]/) {
print "FTPing Number $ch : ", $ncftp_lines[$ch];
print "Please wait.";
chop ($ncftp_lines[$ch]);
system ("$NCFTP $ncftp_lines[$ch]");
} else {
&print15;
}
}
# TODO: Make iarchie check args sent to it to match those valid ones
# allowed by the archie program.
#
# Allow for more than 15 shown matches (add a 'n' for next page
# command)
#
# Write a man page.
#
# This code is by no means to be depended on. It seems to work well
# for me, and I feel that others will benefit from it, so I am posting
# it for others to use who have Perl, archie, and NcFTP installed.
#
# If you want to hack the hell out of it, be my guest. If you release
# a modified version of this iarchie perl script, please be kind and
# mention my name, Jeff Blaine somewhere.
--
J e f f B l a i n e
[email protected]
Perl code: checksummed line-noise with a mission in life. -- R.L. Schwartz