Jul 19
While I was playing with AppleScript earlier this week I wanted to run a shell script I’d written from within Finder rather than from a shell prompt in Terminal.app.
On Windows I tend to write scripts to run under Cygwin and then write a wrapper batch file to run the script under the control of Cygwin’s bash executable.
Turns out the AppleScript solution is identical in principal and is as simple as
do shell script "/full/path/to/shell/script"
You may need to adjust the path to the script dependent upon whether the directory where your script resides is in your $PATH or not.
Jul 13
One of my standard lunchtime reading web sites started me off on this; The Unofficial Apple Weblog got me reading an article on PC Magazine’s site about Argh! moments. That sort of moment when you try to do something really simple on OS X but find it isn’t. In this case, Robyn Peterson’s struggle to mount a network volume on login struck a chord. I’d gone down a similar route and come up with an alias to a network volume in my login items, a solution which seems to be well documented after a quick Google search.
But this wasn’t quite enough for me; my main Mac is an iBook and that means I access network volumes at home and at work so automatic reconnection to a non existant volume at home when I connect my iBook to my employer’s corporate LAN wasn’t really a solution. But from Robyn’s article I decided to take the plunge and write my first AppleScript.
Maybe write is too strong a word; I found the script I needed almost verbatim on the MacFixIt forums. All I needed to do was modify it to my own ends.
Firstly I needed Apple’s Script Editor, which lives in /Applications/AppleScript; then I was able to enter the following script.
tell application "Finder"
open location "smb://user:password@server/share"
end tell
A few words of explanation. Firstly the names have been changed to protect the innocent so I’m not using a real user name, server name or share name and I’m most definately not using a real password. Secondly the network volume I’m connecting to is on a machine running Fedora Core and which is made available to the network using Samba, hence the smb: part of the URI.
I then saved the script somewhere meaningful; I keep a directory called Scripts which unsurprisingly contains scripts so that seemed as good a place as any. I also made sure that when saving the script I saved it as an application and not a script to prevent me being prompted whether I wanted the script to run each time I ran it, as well as ensuring that the Run Only, Startup Screen and Stay Open check boxes were deselected.
Then it was a simple matter to run the script either from a Finder window or via Spotlight and my network volume mounted and was available.
May 30
Emacs is almost infinately customisable; a fact I didn’t really get to grips with this fact untill I found myself on a Fedora Core box a while back with a net connection but without my favourite set of keyboard short cuts. This really brought home how just a few simple customisations can come to be relied upon.
Determined never to be caught short in such a manner again I decided to make my .emacs permanently available, providing I have a net connection that is.
Continue reading »
Mar 01
A while back when I was using Blosxom to power my blog I wrote a plugin called sticky which forced given articles to appear as the most recent.
When I changed my blog over to WordPress the plugin got temporarily misplaced. The plugin is still referenced online at the Unofficial Blosxom User Group plugin registry so now it’s back and can be downloaded again. It’s better to give than receive apparently.