Shell Scripting Introduction Agenda What is Shell Scripting
- Slides: 20
Shell Scripting Introduction
Agenda What is Shell Scripting? Why use Shell Scripting? Writing and Running a Shell Script Basic Commands -@ -ECHO - REM - TITLE - COLOR - PAUSE
Shell Scripting are text files of CLI commands must have the CMD or BAT extension execute a batch file by typing its name at the C: > ü you can execute batch files only from your In Vista, profile directory C: usersprofile. Name, unless authenticated as administrator ü you can use the “Open Command Window Here” by holding the Shift KEY and right clicking on any folder in Explorer ü you can execute a batch file as administrator by holding the Shift key and right clicking on the executable and choosing “Run as Administrator” dialog box
Why use Shell scripting? Automate repetitive tasks which don’t warrant the time to write a C, C++ program Customizing desktop environment Copyingmoving directory trees Renaming groups of files Run a series of procedures with one command Gathering status information and preparing a printed report Create menus and interactive programs to simply the UI Shell scripting is an essential skill of all Windows users to solve programming problems and improve efficiency of the OS
Basic Shell Commands ECHO turns system prompt output on or off and displays messages ECHO ON turns system prompt messages on ECHO OFF turns system prompt messages off ECHO. Creates a blank line @ suppresses the system prompt for a line PAUSE stops execution until user input CLS clears the screen REM prevents execution of a line. Good for comments and debugging
Writing a Shell Script §Use any text editor and save the file with a. cmd §Good programming requires good documentation §Name of file. cmd §Author of the file §Date Last Modified §Purpose of the file §Requirements §White space can be used to make the script easier to read – has not effect on the running of the script §Writing commands in uppercase makes debugging easier, but is not required
Stops system messages Documentation Clears screen Displays message Stops execution until user presses any key Gives user opportunity to stop execution Built in function to stop script execution
Command line input: Command line output:
@ECHO OFF, ECHO Example Create the following Shell script file, name it “greeting. cmd”
ECHO. Example Used to create a blank line to improve appearance of the output
REM Example Used to add comments to make the code more readable
CLS Example Used to clear the screen -- prompt at the top of the window
Title Example Used to add text to the title bar
Color Example Changes foreground and background colour
PAUSE Example Used to temporarily stop script execution
Replaceable Parameters A replaceable parameter is a “placeholder” for information entered on the command line and inserted by the command interpreter into the script during run time Unnamed Replacement Parameters Use %1, %2, %3, %4, %5, %6, %7, %8, %9
Unnamed Replacement Parameters • Names are “hardwired” in the script – no flexibility • No user input before script runs – no dynamic changes • Changes to script must be retyped – thus, error prone
Unnamed Replacement Parameters • Statements are not “hardwired” – gives flexibility • User input on the CLI – allows dynamic changes • No retyping of code – thus, less error prone
Unnamed Replacement Parameters
- Firmness of the yolk and freedom from yolk defects
- Germinal disc in egg
- Lab 7-1 scripting in the bash shell
- Perl shell scripting
- Agenda sistemica y agenda institucional
- Introduction to scripting languages
- Meeting agenda introduction
- Purchasing meeting agenda
- Mentoring kick off meeting
- Inventor scripting
- Lsl programming language
- Loadrunner scripting language
- Gel script
- Advantages of client side scripting
- Client-side scripting examples
- Tabular editor
- Scripting paradigm
- Business object interface
- Paraview python scripting
- Kara james facebook
- Swift (parallel scripting language)