exec

How to fire Mac OS X notifications with AppleScript (and Scala)

Summary: This tutorial demonstrates how to fire MacOS system notifications with AppleScript (and Scala or Java).

In this article I assume that you already know at least a little bit about how to use AppleScript, and just want to know how to trigger a MacOS notification. At the end of the tutorial I show how to invoke the AppleScript code using Scala and Java.

How to run a Unix shell script from the Mac Finder

If you ever want to create a Unix shell script that you can give to someone else so they can double-click it and run it through the Mac OS X Finder, all you have to do is (a) name the file with the ".command" extension and (b) make it executable. So, just name your Mac/Unix script like this:

ShowProcesses.command

Then make it executable, like this:

chmod +x ShowProcesses.command

You can also leave out the usual #!/bin/sh part on the first line.

The Scala Process and ProcessBuilder classes (API documentation)

At the time of this writing, you can't easily find the Scala Process and ProcessBuilder classes (the Scala API documentation), so in an effort to help you (and the search engines) find those classes more easily, here are direct links to them:

How to execute (exec) external system commands in Scala

Scala exec FAQ: How do I execute external system commands in Scala?

When it comes to executing external system commands, Scala is a dramatic improvement over Java. The operators Scala makes available are much more like Perl or Ruby, and the operators themselves are consistent with traditional shell commands, and are therefore easy to remember. Let's take a look at a few examples.

Linux find error - missing argument to -exec

Help, I just got this Linux find error - "Missing argument to -exec".

I just issued a Linux find command, and got the following error message:

find: missing argument to -exec

Amazingly, it turns out that the computer is right, and I messed up my command. I entered my find command like this:

find . -type f -exec grep -il mail

That's the way I want to type this command, but the correct way to type it is to add the extra characters at the end of the command, like this: