Wildflowers Wild wood Dog food Fox in repose Wasp's nest

24th January, 2004

Big Cat Scripts Plugin

Filed under: Technology, — bsag @ 05:01 PM

I’ve been a long time user of Ranchero Software’s NetNewsWire Lite, so I’m a little surprised that I haven’t cottoned on to Big Cat Scripts Plugin before now. I’ve been reading up a bit on Applescript, and saw Big Cat mentioned as an alternative way to launch scripts in a contextual menu. This seems to have a couple of advantages over Apple’s Script Menu which appear on the Menu Bar:

  • The menu pops up under the pointer, so you don’t have move over to the other side of a screen and navigate a long list
  • You can select files in the Finder or text for it to act on—this seems much more straightforward than the Script Menu method (though it’s perfectly possible that I have just misunderstood the latter)

All you need to do is to write Applescripts (or shell scripts) and put them into either the ‘Files’ folder or the ‘Text’ folder in “~/Library/Application Support/Big Cat Scripts/”. The mention of shell scripts intrigued me. It didn’t mention Perl specifically, but I guessed that it should work with any of the scripting languages natively supported by MacOS X, so I decided to give it a try. The other shell script examples seemed to pass the selected files/text as command line arguments, so I knocked up the following little script in Perl:


#!/usr/bin/perl
foreach (@ARGV) {
    exec `chmod +x $_`;
}

I was so chuffed when it worked. It takes each of the selected files and makes them executable. Yes, I know that I could do that in the terminal. Yes, I know that most of this Perl script isn’t Perl. Yes, I know it will fail horribly in all sorts of circumstances. But it’s all mine. It’s quick and dirty, and much easier than navigating to the paths of my Perl scripts and making them executable by hand. I’ve got big plans for a lot more of these little snippets, as well as brushing up the MakeExec example above to test whether it’s operating on a text file and other niceties. I know what I’m going to be doing for the rest of the weekend…

Update: I’m such an idiot that I forgot I had read all about Big Cat less than two months ago on Pete’s weblog—this is a sign of senility, for sure. So there should have been a [via Pete’s weblog] at the bottom of this entry. Though he is currently at a Typepad blog here. OK, I’ll shut up now.

  1. 1

    erm-- if you'll pardon my saying so, it's all geek to me... smile

    (i'm a dork, and i'm fluent in twerp, but i just don't know geek...)

    by stacy @ 24/01/2004 10:01 pm • Permalink

  2. 2

    I've also tried to convince the world that Big Cat was cool!

    http://homepage.mac.com/pete.boardman/weblog/100047.html

    Perhaps your mention of Perl might do the trick...!----- pete: Sometimes I really worry about my memory - or rather the lack of it. I read and enjoyed your post, complete with a lovely image of the Big Cat icon and its clear description of what Big Cat does. Heck, I even commented on the entry. And then I utterly forgot about Big Cat. Not just failed to recall it, but failed to recognise that I'd seen mention of it before when I came across the name in Matt Neuburg's Applescript book. Gah! (slaps forehead). So, folks, credit goes to Pete for introducing me to Big Cat, even though my brain was too pathetic to actually retain the information.

    by bsag @ 24/01/2004 10:02 pm • Permalink

  3. 3

    'chmod' is actually a Perl operator, although it only takes an absolute mode. So you could do it like this - I think:

    foreach (@ARGV) { chmod (stat($)[2]) | 0111, $ }

    which is the equivalent of chmod a+x. This version would need extra error-checking code, though.

    by Caitlin @ 25/01/2004 11:01 am • Permalink

  4. 4

    stacy: Sometimes I talk geek, sometimes I speak almost normal English - that's just me, I'm afraid wink Feel free to ignore the entries with more punctuation than letters.

    Caitlin: I did know about chmod, but I couldn't think how to change the absolute mode to just add the executable bit, so your solution is really interesting. Unfortunately, I've never been able to understand bitwise operators, so I wouldn't have been able to come up with this myself in a million years!

    by bsag @ 25/01/2004 2:02 pm • Permalink

  5. 5

    Setting a bit to 1 is easy: just OR it. Setting it to 0 is messier: you AND the value with a mask which has every other bit set to 1.


    by Caitlin @ 26/01/2004 11:02 am • Permalink

blog comments powered by Disqus

Powered by ExpressionEngine :: © www.rousette.org.uk, 2002-2008 :: [XHTML] [CSS] [508]