When I call a KM macro from a macOS shell command line, like this:
osascript ~/filename.scpt "parameter1"
where ~/filename.scpt is a file that contains this:
tell application "Keyboard Maestro Engine" to do script "TryThis" with parameter "Whatever"
and where my macro contains this action:
The result I get in the shell is this:
T: Do Script V:Whatever B:AppleScript
That makes sense, I guess. So then I tried replacing the file contents with:
tell application "Keyboard Maestro Engine" to do script "TryThis" with parameter "$0"
...(hoping to pass the command line to my macro) but that gave me:
T: Do Script V:$0 B:AppleScript
...even though $0 normally gives you something more useful, like when you do this:
echo $0
... and you at least get this:
-zsh
Ideally what I would like is to pass the standard input in its entirety to the KM macro, but right now I can't even figure out how to send a variable to osascript, let alone standard input. For example, you can probably see what I'm trying to do here, can anyone fix this to make it work?...
var=$(echo "sending some text to an applescript"); osascript ~/filename.scpt $var
And if you can fix the above, can you also fix it so that STDIN is sent to the script? I might be wrong, but from what I can see, if you send STDIN to osascript, it will assume that STDIN is the program, not the data.
I'm not entirely sure what my end goal here is. It's mostly just pure research to understand what is possible. I'm trying to see how much data I can send to a KM macro using the Shortcuts app that calls a KM macro using osascirpt.