How can you pipe the output of an AppleScript to a shell script?

Peter —

Thanks!!!

Not sure if you got my earlier comment, but here it is and an additional question.

First, this is a masterful product. Kudos to you as a fellow long-term programmer.

Second, thanks for this — the editing problems I’ve had were just buggy AppleScript on my part, and the suggestion to run stuff through the AS editor to debug it solved my problems. I was expecting KM to do the same sort of error-reporting as the AS editor itself, and that was not a good idea.

Third, my big problem is finding a way to send an AppleScript result/output to the shell. I suspect it’s something simple and built-in, but my experimentation has so far yielded nothing.

My goal is to simply take the name of a file that Pages is editing and have that filename available to my shell script (also inside KM).

You can do this via a Keyboard Maestro variable.

For example:

image

Results in:

0       5      25

The same as:

echo -n "hello there, how are you?" | wc

I'm going to move this on to a new Topic tho, since it is not related to formatting AppleScript.

If there is other stuff that you need to do in the KM Macro, then returning the data (always a string) to a KM Variable is the way to go.
But if you just need to run a shell script with the results, then you can also make use of the AppleScript do shell script command.