Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unix Scripting Session 1 March 6, 2008.

Similar presentations


Presentation on theme: "Unix Scripting Session 1 March 6, 2008."— Presentation transcript:

1 Unix Scripting Session 1 March 6, 2008

2 A Very Brief History of Unix
Invented in late 1960s at AT&T Bell Labs They were not allowed to sell it, so they licensed it to places like Berkeley, starting with Version 6 Version 7 was the first widely-known version of Unix, incorporating both Bell Labs and Berkeley innovations The 1984 break-up of AT&T allowed it to be sold for commercial purposes

3 Diverging Paths Berkeley’s version became known as the Berkeley Standard Distribution, or BSD, and led to 4.2, 4.3, and 4.4 releases among others AT&T marketed System III, based on Version 7, then later System V, which was a success especially on AT&T 3B series computers Sun Microsystems originally based SunOS on BSD, then joined with AT&T to create SVR4, the core of which became Solaris 2.x

4 Who Cares? Why is the fact that there are multiple versions of Unix important? Because each brought unique tools to the core operating system, leading to many choices to solve problems “There’s more than one right way to do it”

5 The Shell A command line interface in Unix is called a “shell”, and can be used both interactively and for scripting The default shell is /bin/sh, first the Thompson Shell then later the Bourne Shell (v7) The Bourne Shell is the most portable shell, and will be found on all dialects of Unix Easy to program, not friendly interactively

6 The C Shell The C Shell (csh) was written by Bill Joy for BSD (he also wrote vi, NFS, and other things) Syntax based on C, hence the name Much friendlier for interactive use, includes history substitution, aliases and job control Scripting syntax can be ambiguous and confusing, aliases can cause unexpected results Not found on all dialects of Unix

7 Other Shells The Korn Shell (ksh), an enhanced Bourne Shell with many C Shell features plus history editing and enhanced scripting features The Tenex C Shell (tcsh), an enhanced C Shell with history editing and enhanced syntax The Bourne-Again Shell (bash), part of the GNU project and the default /bin/sh on Linux systems, very similar to the Korn Shell

8 What is a Shell Script? A script is a text file containing commands to be executed by a scripting language A shell script specifically uses a shell Scripts must be executable: chmod +x script The shebang (also called a “pound bang”) tells the operating system which shell to use: #!bin/sh #!/bin/csh #!/bin/ksh

9 Other Scripting Languages
Scripting is not just for shells Scripts can be written in awk, sed, and other common Unix utilities Popular add-on scripting languages include Perl, Tcl/Tk, Python, and Ruby Shebangs are used for these as well: #!/usr/bin/awk #!/util/perl/bin/perl

10 Which Ones to Use? For shell scripting, we use the Bourne Shell:
Simple Portable Easy for running Unix commands For other scripting needs, we use Perl: As simple or complex as you want it to be Becoming standard on newer versions of Unix Great for text manipulation and systems programming

11 Our First Bourne Shell Script
#!/bin/sh echo "Hello, world!" for number in ; do echo "$number…\c" done echo "Liftoff!" exit 0

12 References The Creation of the Unix Operating System:
Unix Seventh Edition Manual: Dennis Ritchie's Home Page: The Bourne Shell: The C Shell (Read external links):


Download ppt "Unix Scripting Session 1 March 6, 2008."

Similar presentations


Ads by Google