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.pl < prev    next >
Encoding:
Perl Script  |  1992-04-05  |  1.4 KB  |  62 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 = 7999
  9.  
  10. $archie = "archie.sura.net";
  11. $type = "exact";
  12. $query = <>;
  13. chop($query);
  14. chop($query);
  15. $test = $query;
  16.  
  17. @DaytoMon  = ("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
  18.  
  19.  
  20. if ($test =~ m/000000(.*)\`(.*)\`(.*)\`(.*)$/) {
  21.     $time = $4;
  22.     $size = $3;
  23.     $host = $1;
  24.     $file = $2;
  25.  
  26.     $year = substr($time, 0, 4);
  27.     $month = substr($time, 4, 2);
  28.     $mon  = @DaytoMon[$month];
  29.     $day   = substr($time, 6, 2);
  30.     
  31.     print "Your archie query on $archie found the following matching\r\n";
  32.     print "file or directory:\r\n\r\n";
  33.     print "   Host: $host\r\n";
  34.     print "   Name: $file\r\n";
  35.     print "   Size: $size  (in bytes)\r\n";
  36.     print "   Date: $mon $day, $year\r\n";
  37.     print "\r\n";
  38.     print "To retrieve this file you would use your local ftp client\r\n";
  39.     print "to connect to host $host.  \r\n";
  40.     print "\r\n";
  41.     print ".\r\n";
  42.     exit;
  43. }
  44.     
  45. if ($type eq 'exact') {
  46.     $arg = " -e ";
  47. } else {
  48.     $arg = " -s ";
  49. }
  50.  
  51. $archcmd = "/usr/local/bin/archie -l -t " . $arg . " -h " . $archie . " " . $query;
  52. @result = `$archcmd`;
  53. #print $archcmd;
  54. foreach (@result) {
  55.     ($time, $size, $host, $file) = split;
  56.     print "0$host\t000000$host`$file`$size`$time\t$archiehost\t$archieport\r\n";
  57. }
  58.     
  59. print ".\r\n";
  60. exit;
  61.  
  62.