Preview

Shell Programing

Good Essays
Open Document
Open Document
2683 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Shell Programing
Shell Programming
University of Maryland Eastern Shore Dept. of Computer Science Jianhua Yang

1

CSDP399 Introduction to Unix and Programming

12/22/12

Outline
Unix Shell programming:
Shell scripts.  Definition.  Uses of shell scripts.  Writing shell scripts.

2

CSDP399 Introduction to Unix and Programming

12/22/12

Shell scripts
A shell script is a text file with Unix

commands in it. Shell scripts usually begin with a #! and a shell name (complete pathname of shell).
Pathname of shell be found using the which

command. The shell name is the shell that will execute this script.
 E.g: #!/bin/bash

3

CSDP399 Introduction to Unix and Programming

12/22/12

Shell scripts (contd.)
If no shell is specified in the script file, the

default is chosen to be the currently executing shell.

4

CSDP399 Introduction to Unix and Programming

12/22/12

Shell scripts (contd.)
Any Unix command can go in a shell script
Commands are executed in order or in the

flow determined by control statements.
Different shells have different control

structures
The #! line is very important. We will write shell scripts with the Bourne

shell (bash).

5

CSDP399 Introduction to Unix and Programming

12/22/12

Shell scripts (contd.)
A shell script as a standalone is an

executable program:
Must use chmod to change the permissions

of the script to be executable also.
Can run script explicitly also, by specifying

the shell name.
E.g: $ bash myscript E.g: $ csh myscript

6

CSDP399 Introduction to Unix and Programming

12/22/12

Shell scripts (contd.)
Consider the example
$ bash myscript Invokes the bash shell and then runs the

script using it. Its almost as if we had the line #! /bin/bash in the file myscript. Similarly with the second example using csh. myscript need not be an executable as bash is running the script on its behalf.

7

CSDP399 Introduction to Unix and

You May Also Find These Documents Helpful

  • Good Essays

    A script file is meant to be like a program. The file can be run every time the code needs to be executed without having to retype the code again each time. For this reason, it is important that there are no errors in the…

    • 1559 Words
    • 7 Pages
    Good Essays
  • Better Essays

    Nt1310 Unit 4

    • 3614 Words
    • 15 Pages

    If the following program (myprog) is run from the command line as myprog 1 2 3, What would be the output?…

    • 3614 Words
    • 15 Pages
    Better Essays
  • Powerful Essays

    Unit 3 network discovery

    • 1031 Words
    • 5 Pages

    The shell tries to find an executable program with the same name as the command. When it does, the shell executes the program. When finishing the command put an & ampersand symbol at the end of the command and the command will run in the background. Then a cursor will be displayed immediately to allow the next command to be entered.…

    • 1031 Words
    • 5 Pages
    Powerful Essays
  • Good Essays

    Nt1310 Unit 1 Study Guide

    • 846 Words
    • 4 Pages

    27. In a command line, what is the purpose of the ? in a filename?…

    • 846 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    NT1430

    • 369 Words
    • 2 Pages

    The Bourne shell is the original unix shell, often called a command interpreter, that was developed at AT&T. Named for its developer, Stephen Bourne, the Bourne shell is also known by its program name, sh. The shell prompt (character displayed to indicate readiness for input) used is the $ symbol. The Bourne shell family includes the Bourne, korn shell, bash, and zsh shells.…

    • 369 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    1.) PowerShell is an object-oriented programming language and interactive command line shell for Microsoft Windows.…

    • 2058 Words
    • 7 Pages
    Powerful Essays
  • Powerful Essays

    data and can be initiated from the DOS command prompt? What useful information does this query…

    • 924 Words
    • 4 Pages
    Powerful Essays
  • Good Essays

    | The default shell is bash. The shell allows users to type commands and have the output displayed on the screen.…

    • 489 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    Shell is a piece of software that provides an interface for users of an operating system. Shell provides access to the services of a kernel. Shell makes the user’s job faster and easier in many ways.…

    • 1455 Words
    • 4 Pages
    Powerful Essays
  • Powerful Essays

    70-640 Lesson 11

    • 1132 Words
    • 5 Pages

    __j__ 3. This is a new advanced command-line and scripting interface included in Windows Server 2008.…

    • 1132 Words
    • 5 Pages
    Powerful Essays
  • Satisfactory Essays

    Unit 2 Explore and Discuss

    • 1383 Words
    • 6 Pages

    C.2. But, the linux commands located under this directory are used typically by system aministrator, for system maintenance purpose.…

    • 1383 Words
    • 6 Pages
    Satisfactory Essays
  • Good Essays

    Lesson 11

    • 534 Words
    • 2 Pages

    __J__ 3. This is a new advanced command- line and scripting interface included in Windows Server 2008.…

    • 534 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    code program

    • 317 Words
    • 2 Pages

    (Compilation screenshot) - Insert here a screenshot of the result of compiling the above source code: NetBeans IDE 7.3.1 compiles but it did not go to the screen so I could see it, this is why I sent you a message yesterday to let you know this. But the program did run without any problems.…

    • 317 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    h. The set of all strings consisting of the keyword begin, followed by one or more statements with a semicolon after each one, followed by the keyword end. Use the non-terminal for statements, and do not give productions for it.…

    • 470 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    CISSH

    • 1734 Words
    • 7 Pages

    You need to download the cissh distribution file from Blackboard. There is a zip file,…

    • 1734 Words
    • 7 Pages
    Satisfactory Essays

Related Topics