How shell works Shell reads in input, parse & process it, the resulting string is taken to be argv[] and executed echo a  shell sees “ echo a ” echo gets.

Slides:



Advertisements
Similar presentations
Chapter 9: The TC Shell Everything you thought you knew is now wrong.
Advertisements

CS 497C – Introduction to UNIX Lecture 32: - Shell Programming Chin-Chih Chang
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Integer variables #!/bin/csh # sum of numbers from $argv[1] to $argv[2] set low = $argv[1] set high = $argv[2] set sum = 0 set current = $low while ( $current.
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
CS Lecture 04 Outline Change your shell Sed and awk Tricks with Bash scripts Assignment 1 discussion 1CS 311 Operating SystemsLecture 04.
Information Networking Security and Assurance Lab National Chung Cheng University 1 What Linux is? Free Unix Like Open Source Network operating system.
Fork and Exec Unix Model Tutorial 3. Process Management Model The Unix process management model is split into two distinct operations : 1. The creation.
Shell Script Examples.
2 $ command Command Line Options ls –a –l hello hi Command Arguments.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
CTEC 1863 – Operating Systems Shell Scripting. CTEC F2 Overview How shell works Command line parameters –Shift command Variables –Including.
Lecture 3  Shell Variables  Shell Command History  Job / Process Control  Directory Control.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Chapter 6: Shell Programming
Introduction to Unix (CA263) File Processing. Guide to UNIX Using Linux, Third Edition 2 Objectives Explain UNIX and Linux file processing Use basic file.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
Writing C-shell scripts #!/bin/csh # Author: Ken Berman # Date: # Purpose: display command and parameters echo $0 echo $argv[*]
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
Essential Shell Programming by Prof. Shylaja S S Head of the Dept. Dept. of Information Science & Engineering, P.E.S Institute of Technology, Bangalore
Writing Shell Scripts ─ part 3 CSE 2031 Fall October 2015.
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Shell Programming Any command or a sequence of UNIX commands stored in a text file is called a shell program. It is common to call this file a command.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
1 Week 2 The Crunchy Shell to the Soft and Chewy Kernel… Sarah Diesburg 8/3/2010 COP4610 / CGS5765.
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
CSC 352– Unix Programming, Spring 2015 March 2015 Shell Programming (Highlights only)
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
By James Braunsberg. What are Modules? Modules are files containing Python definitions and statements (ex. name.py) A module’s definitions can be imported.
Intro to UNIX Presented by: Student Ambassadors: Lauren Lewis Martin Sung.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Chapter Six Introduction to Shell Script Programming.
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?
Chapter 5: The Shell The Man in the Middle. In this chapter … The command line Input, output, and redirection Process management Wildcards and expansion.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
Agenda The Bourne Shell – Part II Special Characters Ambiguous File Reference Variable Names and Values User Created Variables Read-only Variables (Positional.
Configuration your environment Many user-configurable Unix programs (such as your shell) read configuration files when they start up. These configuration.
© Prepared By: Razif Razali 1 TMK 265: UNIX SYSTEM CHAPTER FOUR – QUOTING IN DETAIL.
1 Lecture 7 Introduction to Shell Scripts COP 3353 Introduction to UNIX.
Running the Operational Codes for the Brahmaputra Tom Hopson.
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.
Implementation of a simple shell, xssh
Lecture 7 Introduction to Shell Programming
Lecture 7 Introduction to Shell Scripts COP 3353 Introduction to UNIX.
Implementation of a simple shell, xssh
System Programming and administration CS 308
Command line arguments
Command Line Arguments
Writing Shell Scripts ─ part 3
Writing Shell Scripts ─ part 3
Sarah Diesburg Operating Systems CS 3430
Command Line Arguments
Fork and Exec Unix Model
John Carelli, Instructor Kutztown University
CSCI The UNIX System Shell Startup and Variables
The Linux Command Line Chapter 24
Chien-Chung Shen CIS/UD
Lab 4: Introduction to Scripting
Module 4 Command Line Skills
CST8177 Scripting 2: What?.
Chapter 3 The UNIX Shells
Review The Unix Shells Graham Glass and King Ables,
The Linux Command Line Chapter 24
Essential Shell Programming
Presentation transcript:

How shell works Shell reads in input, parse & process it, the resulting string is taken to be argv[] and executed echo a  shell sees “ echo a ” echo gets argv[]= “ echo ” “ a ”, prints out a a=b; echo $a  shell sees “ echo $a ”, change it to “ echo b ” echo gets argv[]= “ echo ” “ b ”, prints out b

How shell works a=b; b=c; echo \$$a  shell sees “ echo \$$a ” shell interprets \$ as the char ‘ $ ’ shell interprets $a as “ b ” the resulting string is “ echo $b ” echo gets argv[]= “ echo ” “ $b ” echo prints out $b on the screen What if I want the value of b printed on the screen?

How eval works a=b; b=c; eval echo \$$a  shell sees “ eval echo \$$a ” shell takes away eval shell interprets \$ as the char ‘ $ ’ shell interprets $a as “ b ” the resulting string is “ echo $b ” because of eval, shell parses this string once again shell interprets $b as “ c ” echo gets argv[]= “ echo ” “ c ” echo prints out c on the screen

Command Path The shell variable $path specifies where to search for commands If not found, shells prints “ Command not found ” To be very specific, use full pathname, such as /sbin/dumpon -v ${dumpdev}

Notable Commands vinum swapon fsck mount (& fstab) find

Difference between. And Sh Both “. script1 ” and “ sh script1 ” executes script1 Both have the same permanent side effect, such as the removal of a file. does the work in the same shell sh does the work in a separate shell If what you want is the side effect within the shell, such as the value of a shell variable, use. instead of sh.