There's probably a better way to do this, but I developed a fairly simple set of tools a while ago to allow me to run google, askJeeves, dictionary, or thesaurus searches from the command line, using perl to parse the search words into a valid URL and then passing that off to lynx. E.g.:

% google cool uses for perl will start lynx in your terminal, at this address: http://www.google.com/search?q=cool+uses+for+perl

You'll need to have lynx in your path, you'll want to change the "use lib" statement in the four tools to the location that the browse.pm module is installed at, and you might need to change the netscape_path and mozilla_path vars at the bottom of browse.pm.

Enjoy!

browse.pm:

#!/usr/bin/perl package browse; use warnings; use strict; use Exporter (); @ISA = qw(Exporter); @EXPORT_OK = qw( jeeves google dictionary thesaurus ); use Getopt::Long; our %pars; sub browser_cmdline { DoGetOptions () if scalar @ARGV; my $site = shift () or die "no site in browse::browser_cmd +line\n"; my $bDontUseArgv = shift () || 0; my $sSearch = join '+', @ARGV unless $bDontUseArgv; # Replace quotes with http friendly %22-s, and replace whitespace +with # query-friendly '+'-s # $sSearch =~ s/"/%22/g; $sSearch =~ s/\s+/+/g; $site .= $sSearch; my $str = ( $pars{browser} eq '' ) ? "lynx -cookies A $site + " : ( $pars{browser} =~ /^m/ ) ? mozilla_path () . " $site +&" : netscape_path () . " $site &"; print "$str\n" and return if $pars{norun}; system $str; } </readmore> sub jeeves { browser_cmdline 'http://www.ask.com/main/askjeeves.asp?ask='; } sub google { browser_cmdline 'http://www.google.com/search?q='; } sub dictionary { browser_cmdline 'http://dictionary.reference.com/search?q='; } sub thesaurus { browser_cmdline 'http://thesaurus.reference.com/search?q='; } sub DoGetOptions { %pars = ( browser => "", norun => 0, help => 0, usage => 0, ); GetOptions ( \%pars, 'browser=s', 'norun', 'help', 'usage', ) or die "bad options $!"; my $help_txt = qq{\tgoogle/jeeves/dictionary/thesaurus \t[-browser] [-norun] [-help] [-usage] \tsearch words list google and jeeves perform a search (at the expected location) on the given words. dictionary looks up the first word on dictionary.com. Quoted strings must be enclosed in single quotes: google '\"one two three\"' -browser n[etscape] launches the search in netscape7, -browser m[ozilla] launches the search in mozilla (default is +lynx). -norun prints out the search URL, but doesn't load it.\n}; die $help_txt if $pars{help} || $pars{usage}; } sub netscape_path { "/usr/local/bin/netscape" } sub mozilla_path { "/usr/local/bin/mozilla" } 1;
dictionary:
#!/usr/bin/perl use warnings; use strict; use lib '/home/kester/bin/'; use browse qw( dictionary ); dictionary ();
google:
#!/usr/bin/perl use warnings; use strict; use lib '/home/kester/bin/'; use browse qw( google ); google ();
thesaurus:
#!/usr/bin/perl use warnings; use strict; use lib '/home/kester/bin/'; use browse qw( thesaurus ); thesaurus ();
jeeves:
#!/usr/bin/perl use warnings; use strict; use lib '/home/kester/bin/'; use browse qw( jeeves ); jeeves ();

In reply to Command Line Google, AskJeeves, Dictionary, and Thesaurus by kesterkester

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.