EMT 2390L Lecture 8 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.

Slides:



Advertisements
Similar presentations
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
Advertisements

Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
EMT 2390L Lecture 4 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Shell Programming Software Tools. Slide 2 Shells l A shell can be used in one of two ways: n A command interpreter, used interactively n A programming.
Linux+ Guide to Linux Certification, Second Edition
Information Networking Security and Assurance Lab National Chung Cheng University 1 What Linux is? Free Unix Like Open Source Network operating system.
Shell Programming Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn the.
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Shell Programming 1. Understanding Unix shell programming language: A. It has features of high-level languages. B. Convenient to do the programming. C.
Linux & Shell Scripting Small Group Lecture 4 How to Learn to Code Workshop group/ Erin.
Using the Bash Shell. Linux Shell Options Linux provides a range of options for shells. bash –The GNU Bourne Again Shell (bash) bsh – The Bourne Shell.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Writing Shell Scripts ─ part 1 CSE 2031 Fall September 2015.
Chapter Nine Advanced Shell Scripting1 System Programming Advanced Shell Scripting.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
Introduction to Unix (CA263) File Processing. Guide to UNIX Using Linux, Third Edition 2 Objectives Explain UNIX and Linux file processing Use basic file.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
GNU Compiler Collection (GCC) and GNU C compiler (gcc) tools used to compile programs in Linux.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
EMT 2390L Lecture 6 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
CS465 - UNIX The Bourne Shell.
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
January 23, 2007Spring Unix Lecture 2 Special Characters for Searches & Substitutions Shell Scripts Hana Filip.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
INT213 Week 1.  A Named storage area (in RAM) that can hold a value (like a mailbox holding a letter)  Contents of a variable can be assigned, changed.
EMT 2390L Lecture 5 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
EMT 2390L Lecture 9 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
Writing Scripts Hadi Otrok COEN 346.
Shell Programming Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn the.
Executable scripts. So far We have made scripts echo hello #for example And called it hello.sh Run it as sh hello.sh This only works from current directory?
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Linux+ Guide to Linux Certification, Second Edition
EMT 2390L Lecture 3 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
1 Week 8 Creating Simple Shell Scripts. 2 Chapter Objectives  In this chapter, you will :  Learn how to create Shell Scripts  Commenting / Making Portable.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
1 Lecture 7 Introduction to Shell Scripts COP 3353 Introduction to UNIX.
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
Linux Administration Working with the BASH Shell.
 Prepared by: Eng. Maryam Adel Abdel-Hady
Lab 7 Shell Script Reference: Linux Shell Scripting Tutorial v1.05r3 A Beginner's handbook
Shell scripts – part 1 Cs 302. Shell scripts  What is Shell Script? “Shell Script is series of command written in plain text file. “  Why to Write Shell.
Bash Scripting CIRC Summer School 2016 Baowei Liu CIRC Summer School 2016 Baowei Liu.
CIRC Winter Boot Camp 2017 Baowei Liu
Prepared by: Eng. Maryam Adel Abdel-Hady
Chapter 9 Shell Programming
By Jonathan Rinfret CREATING A BASH SCRIPT By Jonathan Rinfret
The Linux Command Line Chapter 7
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
The Linux Command Line Chapter 24
Chapter Four UNIX File Processing.
The Linux Command Line Chapter 28
The Linux Command Line Chapter 25
Week 1 – Lesson 2: Creating Shell Scripts, Linux Commands
Lab 7 Shell Script Reference:
The Linux Command Line Chapter 24
Presentation transcript:

EMT 2390L Lecture 8 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts

Outline Shell Scripts Hello World Variables Getting Input

Shell Scripts What is a script? o A file containing a set of commands How to write a shell script? 1.Write a script file using a text editor 2.Make the script executable 3.Specify the location of the script

Hello World Script File Format Features: o #! – shebang character is a sequence that indicates the name of the interpreter to be used to execute the script o # - is a comment o echo – command to display output

Hello World vi hello_world Copy: #!/bin/bash # This is our first script. echo 'Hello World!‘ :wq chmod 755 hello_world./hello_world

Scripts Location Scripts are usually located in the following directories o ~/bin - for personal use o /usr/local/bin – for anyone to use o /usr/local/sbin – for administrators to use o Custom directories added to the PATH variable Best Practices o Use correct indentation techniques for multiple commands o For commands that spam several lines, use the line-continuation sequences (backslash)

Variables To create a variable use a name and assignment statement and assign a value to it. Leave NO SPACES between the name and the assignment statement No datatype need to be specified, as the shell treats everything as a string o name=‘John Smith’ o age=19

Variable Names Conventions You may use alphanumeric characters (letter and numbers) and underscore First character must be a letter or underscore Space and special characters are not allowed Software Engineering Considerations: o Use Pascal case for variables o Use ALL CAPS for constants To read the content of a variable use $ and the variable name o i.e. for variable name use $name

Hello John Replace John with your name

Getting Input To get input you may use the read command o cp hello_world hello_who o vi hello_who o Do the following changes

Read Options

Assignments Check the class OpenLab site for new Labs o Work on the first script of Lab 6 Check Blackboard for new Quizzes Work on your Project