du könntest es versuchen.
tell application "iTerm" activate try set _session to current session of current tab of current window on error say "Error" end try tell _session write text "pwd" set terminalContent to text of _session end tell end tell set output to paragraph -2 of trim(true, terminalContent) on trim(theseCharacters, someText) if class of someText is text and length of someText > 0 then -- default values (all whitespace) if theseCharacters is true then ¬ set theseCharacters to {" ", tab, ASCII character 10, return, ASCII character 0} repeat until first character of someText is not in theseCharacters set someText to text 2 thru -1 of someText end repeat repeat until last character of someText is not in theseCharacters set someText to text 1 thru -2 of someText end repeat end if return someText end trim
Dies gibt die Ausgabe des Befehls zurück, den Sie write text
in Zeile 9 des obigen Codes angeben .