Run shell script and use the result as a variable later to paste it in the window

I need the following:

  1. run shell command to get the string result
  2. need to paste this value in later steps to some window

Please help, not much documentation on this.

You can do this with AppleScript.

First action:

-- run shell script (for example get macOS version)
set theResult to do shell script "sw_vers -productVersion"
-- save to BTT variable
tell application "BetterTouchTool"
	set_string_variable "SavedShellScriptResult" to theResult
end tell

Second action:

-- get the saved shell script result
tell application "BetterTouchTool"
	set theResult to get_string_variable "SavedShellScriptResult"
end tell
-- set the clipboard
set the clipboard to theResult
-- paste to current application
tell application "System Events" to keystroke "v" using command down

Note: You can only past anything to the current window of the current application!

Imprint | Privacy Policy