Last active
May 28, 2020 10:57
-
-
Save mingsai/b11892451d01ba89f4cfc3027f79f590 to your computer and use it in GitHub Desktop.
Applescript - pass variables to the terminal shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Applescript: Run or Call a Shell Script | |
How do run a shell script with an AppleScript? How do I integrate shell scripts into AppleScript? | |
How do I call a shell script called /path/to/chkhost.sh using an applescript? | |
AppleScript is a scripting for Mac OS. It is the Mac OS scripting interface, which is meant to operate in parallel with the graphical user interface. With AppleScript, you can control, and communicate among, applications, databases, networks, Web services, and even the operating system itself. | |
Running Shell Commands From AppleScript Scripts | |
You can easily execute shell commands from your AppleScript using the following syntax: | |
do shell script "command" | |
do shell script "command1; command2" | |
set variableName to do shell script "command" | |
set variableName to do shell script "command1; command2" | |
do shell script "/path/to/yourscript.sh" | |
do shell script "/bin/tcsh /path/to/yourscript.csh" | |
do shell script "/bin/tcsh -c 'command1'" | |
The following script statement uses a do shell script command to get list of the files from the current directory and store it into the AppleScript variable filesLists: | |
set filesLists to do shell script "ls" | |
Task: Pass an AppleScript Variable To Shell Command | |
Use the following syntax (h is an AppleScript variable which is passed to traceroute shell command): | |
set h to "cyberciti.biz" | |
do shell script "traceroute " & h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment