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

Search VersionTracker from the command line UNIX
I've been getting a smidgen irritated by the time it takes for a certain application tracking site's homepage to load, especially when all I want to do is a fast "QuickSearch" on particular keywords in the Mac OS X directory.

Ah, the power of UNIX, allowing "lazy hackers" to waste tons of time creating simple solutions to life's problems! :) In that spirit, I wrote a Perl script to allow keyword searches on VersionTracker from the command line, which then opens up the results in your favorite browser.

Read the rest of the article for the script...

#!/usr/bin/perl -w
#######
# This is a spiffy script written by Robert Daeley to
# search VersionTracker sans loading their frickin' big
# honkin' homepage. With the encouragement of cohort Hans Hickman.
# 27 7 2002 version 0.9.9
#######
# User-specified variables are below.
# To use, simply type ./vtsearch.pl (or whatever you name the script).
# A blank line will appear. Type keyword you want to search by and hit return.
# $browser can be any webbrowser's full name

$browser = "OmniWeb";

#### LEAVE EVERYTHING BELOW AS IS ####

$filter = "MacOSX";
print "Search string: ";
$keyword = <STDIN>;
chomp($keyword);
$url = "http://www.versiontracker.com/mp/new_search.m?productDB=mac&
mode=Quick&OS_Filter=".$filter."&search=".$keyword."&x=0&y=0";
$todo = "\'Tell application \"$browser\" to getURL \"$url\"\'";
system("osascript -l AppleScript -e $todo");
IMPORTANT NOTE: The "$url" line has been split into two for easier reading. Enter it as one line with no spaces between the "&" and "mode". Save the script somewhere in your path, make it executable (chmod 755 Script_Name) and then run it to search VersionTracker. Enjoy and feel free to elaborate. I will leave it as an exercise for the reader to enable searches on VT's other DBs.
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[10,265 views]  

Search VersionTracker from the command line | 25 comments | Create New Account
Click here to return to the 'Search VersionTracker from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
I get a syntax error
Authored by: dm2243 on Jul 30, '02 12:24:24AM
for example: % vtsearch Search string: omniweb syntax error: A ?can't go after this identifier. (-2740) thoughts? (n.b. the $url line was entered correctly)

[ Reply to This | # ]
There's always ...
Authored by: Mikey-San on Jul 30, '02 01:05:05AM

AppleScript or OmniWeb.

In OW, I have shortcuts to search Bartleby.com's copies of American Heitage and Roget's, as well as VT for OS X, OS 9, and Windows. Example:

vt@ http://www.versiontracker.com/mp/new_search.m?productDB=mac&mode=Quick&OS_Filter=MacOSX&search=%@&x=0&y=0

I type "vt frogblast" and it returns the results without me having to load that bloated-ass front page first.

If you use another browser, use an AppleScript:

on run
set theSearch to text returned of (display dialog "Enter search term:" default answer ""
set theURL to "http://www.versiontracker.com/mp/new_search.m?productDB=mac&mode=Quick&OS_Filter=MacOSX&search=" & theSearch & "&x=0&y=0"
tell application "insert browser here"
activate
GetURL theURL -- you may have to use OpenURL instead ...
end tell
end run

That's the string for OS X searches, but you can use any of them.


-/-
Mikey-San



[ Reply to This | # ]
Re: There's always ...
Authored by: dm2243 on Jul 30, '02 02:12:40AM

Thanks - the applescript is very useful. It nows sits in my ScriptMenu.

I want to make one of these for IMDB: what's the trick for finding the right URL?



[ Reply to This | # ]
Re: There's always ...
Authored by: Mikey-San on Jul 30, '02 09:54:09AM

Well, for Bartleby and VT, you simply reverse-engineer the URL you see after you enter a search string.

IMDB is a bit different, it seems. If you have the time, you can try breaking down their search form at:

www.imdb.com/Find

Not as straigtforward as VT, unfortunately, but upon first glance, not necessarily impossible.


-/-
Mikey-San



[ Reply to This | # ]
Thanks, got it....
Authored by: dm2243 on Jul 30, '02 11:37:16AM

for search by title:

set theURL to "http://us.imdb.com/Title?" & theSearch

for search by name:

set theURL to "http://us.imdb.com/Name?" & theSearch



[ Reply to This | # ]
the Omni group is way ahead of you
Authored by: mkoz on Jul 30, '02 01:10:00AM
you can add a shortcut to OmniWeb 4.1 (including at least some of the betas and sneeky peeks) in its preferences. in the "Shortcuts" section, in the "Shortcuts" column put
vt@
and in the "Destination URL" column put (as a single line)
http://www.versiontracker.com/mp/new_search.m?productDB=mac&
	mode=Quick&OS_Filter=MacOSX&search=%@x=0&y=0
Now when you type "vt OmniWeb" in the url field you will get the search results for "OmniWeb" on the version tracker site. you can do this with some other sites, such as google, freshmeat.net and dict.org. i find it really handy to be able to do a google search as soon as i open a new window with the command-N key combo.

[ Reply to This | # ]
Any success?
Authored by: gvitale on Jul 30, '02 04:40:00AM

Has anybody succeeded with this script? I get the same error as dm2243:

% Search_sh
Search string: ccm
syntax error: A Ò can't go after this identifier. (-2740)



[ Reply to This | # ]
Any success?
Authored by: Anonymous on Jul 30, '02 05:53:39AM

I have it working with Mozilla, even though the command
reports that Mozilla gets various numbered errors in
execution.



[ Reply to This | # ]
Success!
Authored by: Anonymous on Jul 30, '02 06:24:24AM

Works perfectly with Mozilla if you change "getURL"
to "OpenURL" -- in the second to last line following
"$todo".

Very cool.



[ Reply to This | # ]
The modified script for Mozilla
Authored by: Anonymous on Jul 30, '02 06:27:24AM

#!/usr/bin/perl -w
#######
# This is a spiffy script written by Robert Daeley to
# search VersionTracker sans loading their frickin' big
# honkin' homepage. With the encouragement of cohort Hans Hickman.
# 27 7 2002 version 0.9.9
#######
# User-specified variables are below.
# To use, simply type ./vtsearch.pl (or whatever you name the script).
# A blank line will appear. Type keyword you want to search by and hit return.
# $browser can be any webbrowser's full name

$browser = "Mozilla";

#### LEAVE EVERYTHING BELOW AS IS ####

$filter = "MacOSX";
print "Search string: ";
$keyword = <STDIN>;
chomp($keyword);
$url = "http://www.versiontracker.com/mp/new_search.m?productDB=mac&mode=Quick&OS_Filter=".$filter."&search=".$keyword."&x=0&y=0";
$todo = "\'Tell application \"$browser\" to OpenURL \"$url\"\'";
system("osascript -l AppleScript -e $todo");



[ Reply to This | # ]
The modified script for Mozilla
Authored by: bluehz on Jul 30, '02 07:48:54AM

Mozilla offers a great method of using keywords to do this same thing: Create a new bookmark with this url:

http://www.versiontracker.com/mp/new_search.m?productDB=mac&mode=Quick&OS_Filter=MacOSX&search=%s&x=0&y=0

Open the bookmark manager and look at the properties of your new bookmark. Give it a short, easy to type keyword name and close the window. Say for example we give it the name "vts". Now whenever I want to search Version "Molasses" Tracker for a name I just enter my keyword + search string:

vts what_i'm_looking_for

The %s in the url acts as the variable replaced at runtime in the URL string. Great feature than can be used most anywhere. Here's another example - the url for MacOSXHints is:

http://www.macosxhints.com/search.php?query=%s&mode=search&datestart=0&dateend=0&topic=0&type=stories&author=0

You can get more info here:

http://www.mozilla.org/docs/end-user/keywords.html



[ Reply to This | # ]
Success!
Authored by: gvitale on Jul 30, '02 07:58:39AM

Thanks!
Yep, the problem is the syntax of the AppleScript part:
for Navigator use get URL
for Mozilla use OpenURL
for IE and OmniWeb use getURL
For other browsers have a look at the Application Dictionary in Script Editor.



[ Reply to This | # ]
Simpler open URL syntax for all browsers
Authored by: houchin on Jul 30, '02 09:00:40AM

Hi all,

You can actually simplify things a bit and create an applescript that works will all browsers, since the perl script from daeley is actually using AppleScript to do most of the work.

Instead of using GetURL, openURL, ... use:
system "osascript -e 'tell application \\"$browser\\" to open location \\"$url\\"'";


If you want this to run in your default browser, I believe you can just use:
system "osascript -e 'open location \\"$url\\"'";

I've tested this with IE, OmniWeb, Mozilla and Chimera.



[ Reply to This | # ]
Simpler open URL syntax for all browsers
Authored by: balston on Jul 30, '02 03:54:21PM

Tried this script modification and it didn't work. Got the following errors:


Scalar found where operator expected at /Users/balston/bin/vt line 25, near ""osascript -e 'tell application \\"$browser"
(Missing operator before $browser?)
syntax error at /Users/balston/bin/vt line 25, near ""osascript -e 'tell application \\"$browser"
Backslash found where operator expected at /Users/balston/bin/vt line 25, near "$browser\"
(Missing operator before \?)
Scalar found where operator expected at /Users/balston/bin/vt line 25, near "" to open location \\"$url"
(Missing operator before $url?)
Backslash found where operator expected at /Users/balston/bin/vt line 25, near "$url\"
(Missing operator before \?)
Execution of /Users/balston/bin/vt aborted due to compilation errors.


I replaced the entire line:

$todo = "\'Tell application \"$browser\" to getURL \"$url\"\'";

with the suggested line with no luck. I'm probably just don't know what the heck I'm doing. I don't know Perl or AppleScript very well at all. But, any input would be appreciated.



[ Reply to This | # ]
MacUpdate
Authored by: macupdate on Jul 30, '02 11:05:01AM

Or just visit MacUpdate (www.macupdate.com)

You can bookmark the power search page at:
http://www.macupdate.com/powersearch.php

or simple add keywords to the end of this URL:

http://www.macupdate.com/search.php?keywords=



[ Reply to This | # ]
or a bookmarklet...
Authored by: verdon on Jul 30, '02 11:12:29AM

I use this as a bookmark for searching OSX listings,

javascript:void(search=prompt('Enter%20text%20to%20search%20using%20Version%20Tracker.',''));if(search)void(location.href='http://www.versiontracker.com/mp/new_search.m?productDB=mac&mode=Quick&OS_Filter=MacOSX&search='+escape(search))

note: all one line



[ Reply to This | # ]
or a bookmarklet...
Authored by: Jay on Jul 30, '02 02:34:32PM

Wow, that works great in Netscape 7. Thanks!



[ Reply to This | # ]
or a bookmarklet...
Authored by: verdon on Jul 30, '02 07:42:23PM

I wish I could remember where I found the first one of these so I could properly credit the source, but I can't. I've made a few others on the same theme and find them very useful...

VersionTracker Classic:

javascript:void(search=prompt('Enter%20text%20to%20search%20using%20Version%20Tracker.',''));if(search)void(location.href='http://www.versiontracker.com/mp/new_search.m?productDB=mac&mode=Quick&OS_Filter=MacOS&search='+escape(search))

Google:

javascript:void(q=prompt('Enter%20text%20to%20search%20using%20Google.',''));if(q)void(location.href='http://www.google.com/search?client=googlet&q='+escape(q))

etc.



[ Reply to This | # ]
or a bookmarklet...
Authored by: kerim on Nov 26, '02 12:56:34AM

Here is the bookmarklet for VT OS X:

javascript:void(search=prompt('Enter%20text%20to%20search%20using%20Version%20Tracker.',''));if(search)void(location.href='http://www.versiontracker.com/mp/new_search.m?productDB=mac&mode=Quick&OS_Filter=MacOSX&search='+escape(search))

The only difference being an extra X ...

This works great in Chimera.

Check out Bookmarklets.com for more!



[ Reply to This | # ]
or a bookmarklet...
Authored by: hombre on Jul 30, '02 06:58:47PM

I assume you are not using OmniWeb. In OS 9, I had bookmarklets in FinderPop that would pop up only when I was in IE, which pleased me to no end. You haven't gotten bookmarklets to work in OmniWeb, have you? I have had no luck, presumably because of the tepid javascript support.



[ Reply to This | # ]
or a bookmarklet...
Authored by: verdon on Jul 30, '02 07:46:25PM

No, sorry, I'm not. I've tried OmniWeb a few times and maybe it's just my system (G3 Pismo 400MGHZ / 320MB Ram / OSX 10.1.5) but I've found OmniWeb god-awful slow and cumbersome feeling. I'll have to stick to IE, at least til Chimera is a little more mature :)



[ Reply to This | # ]
Sherlock
Authored by: Anonymous on Jul 30, '02 03:48:09PM

There's a built-in Sherlock plug-in for VersionTracker in case you all forgot.



[ Reply to This | # ]
Sherlock
Authored by: Anonymous on Jul 30, '02 03:50:21PM

There's a built-in Sherlock plug-in for VersionTracker in case you all forgot.

(FYI, there's also one for the IMDB, for the poster who wanted to write a search script)



[ Reply to This | # ]
Better Version
Authored by: iacas on Jul 30, '02 06:23:07PM

Here's a better version that allows you to type "vt blah" or "vt 'blah blah'" (I aliased the script to "vt" in my shell). Anyway, it takes arguments from the CLI and doesn't force you to enter return twice, plus it can do multiple searches at once.


#!/usr/bin/perl -w

$filter = "MacOSX";
$browser = "OmniWeb";

if(!@ARGV)
{
print "Search string: ";
chomp($keyword = <STDIN>);
@args = split ' ', $keyword;
}
else
{@args = @ARGV}

for my $search (@args)
{
$url = "http://www.versiontracker.com/mp/new_search.m?productDB=mac&mode=Quick&OS_Filter=".$filter."&search=".$search;
$todo = "\'Tell application \"$browser\"\\nactivate\\ngetURL \"$url\"\\nend tell\'";
system("/usr/bin/osascript -l AppleScript -e $todo");
}



[ Reply to This | # ]
Here's a python translation also ...
Authored by: buc40 on Jul 30, '02 09:53:26PM

I threw together this quick python translation for
anyone that is interested:

#!/usr/bin/env python
import os
import sys
browser = "Navigator"
filter = "MacOSX"
keyword = sys.argv[1]
url = "http://www.versiontracker.com/mp/new_search.m?productDB=mac&mode=Quick&OS_Filter=%s&search=%s&x=0&y=0" % (filter, keyword)
todo = ""'Tell application "%s" to Get URL "%s"'"" % (browser, url)
os.system("osascript -l AppleScript -e '%s'" % todo)

Save as vt.py and just change
the permissions "chmod 0755 vt.py" and run as follows:

./vt.py "keyword"

substitute your search term for "keyword" without any quotes. For
example:

./vt.py database


Good Luck.
SA



[ Reply to This | # ]