I want to get the output of a shell command run through iTerm2's applescript into an applescript variable. I tried the following but it does not work:
tell application "iTerm"
activate
try
set _session to current session of current terminal
on error
say "Error"
end try
tell _session
set Directory to write text "pwd"
get Directory
set Directory to exec command "pwd"
get Directory
end tell
end tell
Thanks for your help!