Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Search wikipedia from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Search wikipedia from the command line
Authored by: svanstrom on Dec 07, '04 09:05:02AM

For the past cpl of years I've been using this quick hack to search some sites (Macosxhints, Google [mostly pre Safari], wikipedia etc); you only have to change one line to make it work with other sites.

I use the same ones on my Mac and on other OS:es; the code aint pretty, but it works the way _I_ want it to. =)

#!/usr/bin/perl -w
# 2002 © svanstrom.com - all rights reserved
# <URL: http://www.svanstrom.com >

foreach (@ARGV) {$_ = "\"$_\"" if /\s/};

($q = "@ARGV") =~ s/([\W])/"%" . uc(sprintf("%2.2x",ord($1)))/eg;
$q = "http://en.wikipedia.org/wiki/Special:Search?search=$q";

if (! exists $ENV{REMOTEHOST} && $ENV{OSTYPE} eq 'darwin') {
        print <<'END'

I hope you'll find it! =)

        /tony@svanstrom.com
<URL: http://www.svanstrom.com/ >

END
;
        system('open', $q)
} else {
        system("lynx", "$q");
        print <<'END'

I hope you found it! =)

        /tony@svanstrom.com
<URL: http://www.svanstrom.com/ >

END
;
}

---
--


[ Reply to This | # ]