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)
Airy
December 4, 2024, 5:37pm
2
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%"
devoy
December 4, 2024, 5:39pm
3
Bonus (tiny) tip:
grep "[R]emote Desktop.app"
and you don't need the grep -v grep
1 Like
Nige_S
December 4, 2024, 5:53pm
4
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