home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Unix / go4gw1.1 / g2netfind < prev    next >
Encoding:
Text File  |  1993-04-30  |  2.5 KB  |  102 lines

  1. #!/usr/local/bin/perl
  2.  
  3. #----------------------------------------------------------------------
  4. # variables you should change:
  5.  
  6. $dblookupcmd   = "/home/mudhoney/netfind/nf/dblookup";
  7. $netfindcmd    = "/home/mudhoney/netfind/nf/netfind";
  8.  
  9. #----------------------------------------------------------------------
  10.  
  11. # gateway from gopher to netfind, requires netfind 3.46 or above
  12.  
  13.  
  14. sub netfind_main {
  15.     
  16.     local($_) = @_;
  17.     
  18.     if (/^$/) {
  19.     &Greply("7Search Netfind for E-mail addresses\t$Ggw dblookup\t$Ghost\t$Gport");
  20.     &Greply("0How to Use the Gopher to Netfind Gateway\t$Ggw help\t$Ghost\t$Gport");
  21.     &Greply(".");
  22.     exit;
  23.     }
  24.     
  25.     # Filter out naughtyness that might subvert security
  26.     s/\"\`\$//g;
  27.  
  28.     ($cmd, $query, $gplus) = split('\t');
  29.  
  30.     if ($gplus eq '!') {
  31.     print ".\r\n";
  32.     exit;
  33.     }
  34.  
  35.     if ($cmd =~ /^help/) {
  36.     &Greply("This Gopher gateway performs Netfind searches.  It uses the");
  37.     &Greply("go4gw software.  To use this gateway supply keywords for a");
  38.     &Greply("Netfind search.  A list of matching domains will be returned as");
  39.     &Greply("documents.  Choose from one of the domains to retrieve the results");
  40.         &Greply("from a Netfind search for that domain.  Due to the strict query");
  41.     &Greply("format for Netfind, keywords must be in the format: name key key...");
  42.     &Greply("");
  43.     &Greply("For example, to find information about Darren Hardy at the University");
  44.     &Greply("of Colorado in Boulder, use the keywords 'hardy boulder colorado' or");
  45.     &Greply("'hardy boulder colorado computer science'.");
  46.     &Greply(".");
  47.     exit;
  48.     }
  49.     
  50.  
  51.     if ($cmd =~ /^dblookup/) {
  52.  
  53.     &Gabort("0Mangled Search request, need name *and* domain")
  54.         if (length($query) <1);
  55.  
  56.     $query =~ s/\./ /;
  57.     $query =~ s/([^A-Za-z0-9 ])/\\$1/g;
  58.     $query =~ /([^ ]*) (.*)$/;
  59.     $name = $1;
  60.     $domain = $2;
  61.  
  62.     # Need to test for empty values here..
  63.     if ($name eq "" || $domain eq "") {
  64.         &Gabort("0Mangled Search request, need name *and* domain");
  65.     }
  66.  
  67.     $dbcmd = "$dblookupcmd \"$domain\"";
  68.     open(Dbfd, "$dbcmd |");
  69.     while (<Dbfd>) {
  70.         chop;
  71.         $title = $_;
  72.         /^([^ ]+) .*/;
  73.         $domain = $1;
  74.         &Greply("0$title\t$Ggw netfind $name $domain\t$Ghost\t$Gport");
  75.     }
  76.     close(Dbfd);
  77.     } 
  78.  
  79.     if ($cmd =~ /^netfind/) {
  80.  
  81.     $query =~ s/([^A-Za-z0-9. ])/\\$1/g;
  82.     ($netfind, $name, $domain) = split(' ');
  83.     $brokendomain = $domain;
  84.     $brokendomain =~ s/\./ /g;
  85.  
  86.     $nfcmd = "$netfindcmd -L $domain $name $brokendomain </dev/null2>1";
  87.     open(nffd, "$nfcmd|");
  88.     while (<nffd>) {
  89.         chop;
  90.         &Greply($_);
  91.     }
  92.     print "\r\n";
  93.     close(nffd);
  94.     }
  95.  
  96.     &Greply(".\r\n");
  97.     exit;
  98.     
  99. }
  100.  
  101. 1; # for reqiure
  102.