home *** CD-ROM | disk | FTP | other *** search
/ ftp.muug.mb.ca / 2014.06.ftp.muug.mb.ca.tar / ftp.muug.mb.ca / pub / src / gopher / gopher1.01 / misc / archie-gopher-gw / gateway.new~ < prev    next >
Encoding:
Text File  |  1992-06-22  |  1.6 KB  |  69 lines

  1. #!/usr/local/bin/perl
  2.  
  3. # gateway from gopher to archie
  4. # this is the "brute force" kind of approach; a tidier solution
  5. # would speak the prospero protocols directly.
  6.  
  7. $archiehost = "mudhoney.micro.umn.edu";
  8. $archieport = 70;
  9.  
  10. $archie = "archie.sura.net";
  11. $type = "exact";
  12. $query = shift;
  13. $test = $query;
  14.  
  15. @DaytoMon  = ("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
  16.  
  17.  
  18. if ($test =~ m/000000(.*)\`(.*)\`(.*)\`(.*)$/) {
  19.     $time = $4;
  20.     $size = $3;
  21.     $host = $1;
  22.     $file = $2;
  23.  
  24.     $year = substr($time, 0, 4);
  25.     $month = substr($time, 4, 2);
  26.     $mon  = @DaytoMon[$month];
  27.     $day   = substr($time, 6, 2);
  28.     
  29.     print "Your archie query on $archie found the following matching\r\n";
  30.     print "file or directory:\r\n\r\n";
  31.     print "   Host: $host\r\n";
  32.     print "   Name: $file\r\n";
  33.     print "   Size: $size  (in bytes)\r\n";
  34.     print "   Date: $mon $day, $year\r\n";
  35.     print "\r\n";
  36.     print "To retrieve this file you would use your local ftp client\r\n";
  37.     print "to connect to host $host.  \r\n";
  38.     print "\r\n";
  39.     print ".\r\n";
  40.     exit;
  41. }
  42.     
  43. if ($type eq 'exact') {
  44.     $arg = " -e ";
  45. } else {
  46.     $arg = " -s ";
  47. }
  48.  
  49. $archcmd = "/usr/local/bin/archie -l -t " . $arg . " -h " . $archie . " " . $query;
  50. @result = `$archcmd`;
  51. #print $archcmd;
  52. foreach (@result) {
  53.     ($time, $size, $host, $file) = split;
  54.     $year = substr($time, 0, 4);
  55.     $month = substr($time, 4, 2);
  56.     $mon  = @DaytoMon[$month];
  57.     $day   = substr($time, 6, 2);
  58.     if ($file ~= m./$.) {
  59.         $objid = "1";
  60.     } else {
  61.         $objid = "0";
  62.     }
  63.     print "$objid$mon $day, $year $host:$file\tftp:$host@$file\t$archiehost\t$archieport\r\n";
  64. }
  65.     
  66. print ".\r\n";
  67. exit;
  68.  
  69.