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 " &
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop