#!/usr/bin/perl ########################## #$Id: netsearch 24 2003-01-16 00:33:12Z steve $ #$Log$ #Revision 1.2 2003/01/16 00:33:12 steve #system should be done better # #Revision 1.1 2002/12/13 21:08:59 steve #Initial revision # ########################## use Getopt::Std; getopts("wuhgGicelfmb:"); # set this to the program that you want to have called upon a search my $cmd = "mozilla"; usage() if $opt_h; if( @ARGV ){ $search = join " ", @ARGV; }else{ my @in = ; chomp @in; $search = join " ", @in; } $search =~ s/^\s*(.+)\s*$/$1/; $google = "http://www.google.com/search?q=SRCH"; $googleimage = "http://www.google.com/images?q=SRCH"; $googlelucky = "http://www.google.com/search?q=SRCH&btnI="; $googlecache = "http://www.google.com/search?q=cache:SRCH"; $everything = "http://www.everything2.com/?node=SRCH&type=e2node&type=superdoc&searchy=search"; $loth = "http://elfwood.lysator.liu.se/loth/ELFWOOD/SRCH/"; $freshmeat = "http://freshmeat.net/search/?q=SRCH"; $memepool = "http://www.memepool.com/Search/index.cgi?terms=SRCH"; $url_only = "SRCH"; # if it looks like a url, just open it. my word, what an ugly regexp.. if( $search =~ /^(\w{2,8}:\/\/)?(?:(?:\w+\:)?\w+\@)?(\w+\.)+\w{1,6}(?![\.\w])/ || $search =~ /^(\w{2,8}:\/\/)/ ){ $url = $url_only; }else{ $url = $google; } if( $opt_w || $opt_u || $url eq $url_only ){ $search =~ s/\s+//gs; }else{ $search =~ s/\s+/\%20/gs; } if( $opt_l ) { my $elfwood = $search; $elfwood =~ s/^(.)(.).+/$1\/$2/; $url = $loth; $url =~ s/ELFWOOD/$elfwood/; } $url = $everything if $opt_e; $url = $freshmeat if $opt_f; $url = $googlelucky if $opt_G; $url = $googleimage if $opt_i; $url = $googlecache if $opt_c; $url = $memepool if $opt_m; $url = $url_only if $opt_u; $url =~ s/SRCH/$search/; $cmd = $opt_b if $opt_b ne ""; #print "$cmd $url\n\n"; system $cmd, $url; sub usage{ print <