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

Search macosxhints from the command line UNIX
A simple hint, based on the Search VersionTracker hint. Here's how to rework the script to search from the command line:
#!/usr/bin/perl -w
$browser = "Mozilla";
print "Search string: ";
$keyword = <STDIN>;
$url = "".$keyword."&
$todo = "\'Tell application \"$browser\" to OpenURL \"$url\"\'";
system("osascript -l AppleScript -e $todo");
NOTE: The $url line has been broken into two lines for display purposes; enter it on one line with no spaces.

You must modify the script if you use a different browser. "Explorer" instead of "Mozilla" and getURL instead of OpenURL. Read the other hint and the comments for more details on creating and saving this script. But this works like a charm for me in Mozilla.

[Editor's note: To extend the concept in these two hints to any searchable site, just visit the site in question and execute a search. Copy the URL from the results page and then use that in the "$url" line. Replacing your test search term in the URL with the reference to $keyword as shown in the two hints, and you have an instant command-line search tool for that particular website.]
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)

Search macosxhints from the command line | 5 comments | Create New Account
Click here to return to the 'Search macosxhints from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Fix for omniweb
Authored by: FlyBoy on Aug 01, '02 02:59:04PM
This hint doesn't work for omniweb since the OpenURL command is not part of its Applescript suite; however, changing OpenURL to GetURL fixes it:
#!/usr/bin/perl -w $browser = "Omniweb"; print "Search string: "; $keyword = ; chomp($keyword); $url = "".$keyword."&mode=search&datestart=0&dateend=0&topic=0&type=stories&author=0"; $todo = "'Tell application "$browser" to GetURL "$url"'"; system("osascript -l AppleScript -e $todo");

[ Reply to This | # ]
Authored by: robg on Aug 01, '02 06:48:40PM

Check the original code for the proper formatting of the line with backslashes; Geeklog ate the ones in the original comment (argh ... I really want the new engine!!)


[ Reply to This | # ]
Fix for omniweb
Authored by: RudeDawg on Aug 05, '02 04:20:41PM

Not to nitpick, but this can be done easily in the "Shortcut Preferences" pane in OmniWeb.

One is already set up for searching Google in the address line.
This works for Mac OSX Hints...

Shortcut - hint@
Destination URL -"&

Again, type the URL in one line. Type "hint (space) (search term)" in the address bar, and presto!

[ Reply to This | # ]
the shell version
Authored by: mervTormel on Aug 01, '02 08:09:49PM

here's a shell version that uses the fink tool 'openurl' ; that will open an url in the default browser. this avoids the overhead of perl and applescript.

% cat shmox


# file: shmox - search hints at

# what's the site?

# what's the query setup?

# keyword on the command line? deal with spaces in the query

# what's the query completion?

# no keyword on the command line? gotta have something to search for
[ "${keyword}" ] || { echo -n "search ${qSite}: "; read keyword; }

# construct the url

# want to see the crafted query? uncomment this tripe
# /bin/echo "submit ${qSite} query: "; echo ${url} | /usr/bin/fold

# splat
/sw/bin/openurl "${url}"

[ Reply to This | # ]
Minor nitpicking
Authored by: Carthag on Aug 04, '02 11:10:39AM
Perl does variable interpolation on double-quoted strings, so you don't have to put the $keyword outside and concatenate it with .s...
$url = "$keyword&
will work as well... Just wondering why it's used in two of the places but not in the others. :)

[ Reply to This | # ]