Reputation: 21
I'd like to write an AppleScript command that can run Terminal and write "purge" , press return and then cmd-q.
I tried this way:
tell application "terminal" keystroke ??????????? (I don't know how to use keystrokes commands!) end tell
I'd like to compose this command with AppleScript to free RAM space only starting a script without third party apps.
Upvotes: 0
Views: 3222
Reputation: 16285
You have two options:
Shell scripting:
do shell script "purge"
Keystrokes:
tell app "Terminal" to activate
tell app "System Events" to keystroke "purge"
tell app "System Events" to keystroke return
tell app "Terminal" to quit
Upvotes: 0
Reputation: 10564
tell application "Terminal"
activate
tell application "System Events"
keystroke "sudo"
keystroke return
end tell
end tell
or the answer by Lauri, which does the same thing without showing the Terminal or having to activate it.
Upvotes: 1