Shell script never terminates

I am trying to create a script to quit Remote Desktop on a remote host, however the shell script never seems to return. While pasting the command into terminal works perfectly.

ssh mtennes@%Variable%host%.local 'ps -ax' | grep "Remote Desktop.app" | grep -v grep | awk '{print $1}'

Quit Remote Desktop.kmmacros (3.5 KB)

I think your problem is that you can't paste variables into a shell script that way. Read this page and check the examples:

https://wiki.keyboardmaestro.com/action/Execute_a_Shell_Script

Basically, you have to say "$KMVAR_myvarname" not "%Variable%myvarname%"

Bonus (tiny) tip:
grep "[R]emote Desktop.app" and you don't need the grep -v grep

1 Like

Never one to rain on a shell script parade, but have you tried:

ssh mtennes@${KMVAR_host}.local 'osascript -e "tell application \"Remote Desktop\" to quit" '
2 Likes

I loved thunderstorms!

1 Like