How to Write Script Apps
Writing script applications, or script apps, is a kind of miniature programming. Although the tasks you can perform with a script is more limited than what you can do with a full programming language, scripting languages are easier to learn and faster to write than full-blown applications. By writing script apps, you can automate many common and time-intensive system administration tasks on Unix-based systems such as Linux or Mac OS X.
Instructions
-
-
1
Open a terminal emulator. For Macs, this will be located in the "Utilities" subfolder of the "Applications" folder. For Linux systems, this will be found in either the "Accessories" or "System" submenu of the main menu, which will be found in the top left-hand corner of systems using the GNOME desktop environment. For systems using the KDE desktop environment, this menu will be found in the bottom left-hand corner of the screen.
-
2
Type "cd" followed by the directory in which you want to store your script.
-
-
3
Create your file by typing "nano my-script-name.sh" where "my-script-name" is the name you will give your script.
-
4
Type "#!/bin/bash" in the very first line of your script source code, so your system knows to execute the code as a script.
-
5
Type in the rest of your code for your script.
-
6
Press "Ctrl+O" to save your script source code, then press "Enter" to confirm.
-
7
Press "Ctrl+X" to exit the editor.
-
8
Type "./my-script-name.sh" to execute the script app you just wrote.
-
1
References
- Photo Credit Jupiterimages/Photos.com/Getty Images