CIS52 Week 2 - PowerPoint PPT Presentation

1 / 43
About This Presentation
Title:

CIS52 Week 2

Description:

CIS52 Week 2 – PowerPoint PPT presentation

Number of Views:87
Avg rating:3.0/5.0
Slides: 44
Provided by: charlesand
Category:
Tags: att | cis52 | week

less

Transcript and Presenter's Notes

Title: CIS52 Week 2


1
CIS52 - Week 2
  • Printing (ATT versus BSD)
  • Introduction to the Bourne Shell

2
Class 1 Review
  • For anyone wearing blue
  • Name the three most common shells
  • What command is used to get help in unix
  • Who were the primary authors of Unix
  • What two organizations were most influential in
    the development of Unix
  • How do you get a listing of your home directory

3
Class 1 Review
  • For anyone in rows one or two
  • pwd
  • cd
  • cat
  • dog
  • tail
  • wc

4
Class 1 Review
  • What are the three modes in vi
  • Name four ways to get into input mode
  • While in command mode, how do you move your
    cursor one character to the left
  • How do you save your work in vi
  • How do you delete a line
  • How do you go to the fourth line

5
Printing (ATT variety)
  • Typical command is lp
  • Typical syntax lp myfile
  • lp -o nobanner myfile
  • Unix returns with acknowledgement
  • request id is okidata-3 (if that is the printer
    name)
  • Cancel your print job
  • cancel okidata-3

6
Printing Continued
  • To get status
  • lpstat
  • To get the mail system to alert you when printing
    has completed
  • lp -m
  • Printing on YOUR version of Standard Unix is
    guaranteed to be different

7
Printing BSD vs ATT
  • BSD (also LINUX)
  • lpr
  • lpq -Pokidata n01
  • lpr-Pokidata -5 file
  • lpq -Pokidata
  • lprm -Pokidata-1
  • lpr -Plaser myfile
  • ATT
  • lp
  • lpstat
  • lp -n5 file
  • lpstat -t
  • cancel okidata-1
  • lp -dlaser myfile

8
Time for Some Feedback
  • Does lp trace its roots to UC Berkeley?
  • NO .. lp indicates ATT
  • How do you get the status of a job ?
  • lpstat in ATT
  • lpq in BSD
  • How do you cancel a job using ATT ?
  • cancel request

9
Printing for the printer-less
  • How do you print using the SCC LAB facility?
  • Use Telnet logging feature to record data going
    to screen to a file on local machine
  • OR
  • use FTP to grab file from server, print in w95
    (using notepad)

10
This question is for anyone wearing red
  • Do you remember the command option (using ATT
    syntax) for skipping the printing of a banner?
  • What are the pros and cons of teaching users to
    use this option?

11
And now .. On to the SHELL!
  • Some Background
  • The Command Line Syntax
  • How the tty driver gets involved
  • Special characters
  • Streams and Redirection
  • Pipes and Filters
  • Feedback

12
Some Background
  • The Shell provides an interface for
  • controlling programs
  • handling input and output
  • The Bourne, Korn and C shells
  • ARE LINE ORIENTED
  • DATE BACK TO THE USE OF THE TELETYPE

13
The Command Line Syntax
  • Command option_arguments other_arguments
  • most commands accept one or more arguments
  • An argument is a filename, string of text or some
    other object
  • some, like ls do not require any
  • an option argument usually starts with a dash (-)
    and modifies the command somehow

14
Command Examples
  • ls
  • ls -l
  • cat myfile1 myfile2 myfile3
  • sort -r myfile
  • grep aardvark myfile
  • grep -v aardvark myfile

15
More fascinating facts about Commands
  • Command lines must be no greater than 512
    characters (on my version of unix)
  • more than one command can be put on a line if you
    separate them with a colon
  • ls cat myfile
  • commands can be grouped with ( )
  • cd (cd /mysubdir pwd ls -a) pwd
  • cd within () only affects commands in ()

16
How the tty driver gets involved
  • The tty driver manages communication between UNIX
    and the terminal
  • It buffers lines until you type a return key
  • After a return key is typed, it passes the
    complete line to the shell
  • The tty driver responds to special characters
    (backspace, U, r or R)

17
Telnet and special characters
  • Issue the stty-a command
  • presents special key sequences that let you kill
    a process (\ C for example)
  • Our WIN95 Telnet seems to capture these key
    strokes, so they are not passed to the UNIX
    server
  • Log into the server from another terminal to kill
    a process

18
Method to kill a process
  • Login to UNIX on another terminal
  • Issue the ps command
  • Write down lowest process id number
  • (this was for your prior runaway session)
  • Issue kill -9 xxxx
  • where xxxx is the number

19
Special characters
  • The SHELL has first grabs on input sent from a
    terminal via the tty driver.
  • It may, in looking at the stream of characters,
    decide that one of them is special
  • Some of these special characters are used for
    filename expansion, paths,redirection,
    sequencing, etc

20
Filename Expansion
  • Asterisk () wildcard for all characters, except
    those that start with a period
  • cat cis52 or ls .c
  • Question Mark (?) wildcard for a single
    character
  • ls assignment?
  • Character Class
  • ls assignment123

21
Formal Definition
  • Filename expansion refers to the process of
    expanding ambiguous file references
  • also referred as globbing
  • (but only by Unix nurds who want you to think
    they are wonderful)

22
Other Special Characters
  • for command sequencing (separation on the same
    line)
  • used to run process in the background (which
    lets you keep working at the terminal)
  • / part of a pathname
  • cat /class/n01/myfile
  • comment (in shell script)

23
Streams and Redirection
  • Stream a sequenced source of bytes
  • keyboard is input stream
  • screen is output stream
  • a file can be used with either
  • input if read
  • output if write
  • Tapes and Disks can be used with input or output
    streams

24
(No Transcript)
25
Unix Streams
  • All programs are connected to 3 Streams
  • 0 Standard Input (kb is default)
  • 1 Standard output (screen is default)
  • 2 Standard Error (screen is default)
  • Redirection refers to a way in which you can get
    the shell to alter these defaults

26
Redirection
  • Command filename
  • takes output from a command and sends it to a
    file
  • command filename
  • takes output from a command and appends it to
    a file
  • command
  • takes input from a file and sends it to the
    command

27
Redirection Continued
  • command 1 filename is what is really happening
    when you type
  • command filename
  • command 2 filename sends standard error to a
    file

28
Examples
  • wc file1
  • wc file1 file2
  • wc file2
  • wc file1 file2
  • wc file 2
  • start typing one or more lines
  • d

29
Examples
  • cat apple orange
  • cat apple orange apple
  • cat homework? temp
  • cat ?ome temp

30
Filters
  • A filter is a command that expects input directly
    from the standard input and sends output to the
    standard output
  • ls is not one .. It does not read data from
    standard in or a file.
  • wc however, is a filter (as are many of the
    commands we will talk about)

31
Filters continued
  • A filter
  • reads input stream
  • transforms the data
  • writes an output stream
  • can read/write to any file or device

32
Pipes
  • A pipe is similar to redirecting the output of a
    command to a file, except that it redirects it to
    ANOTHER COMMAND
  • The vertical bar is used to designate a pipe
  • The Shell establishes the connection
  • Data in the pipe may be buffered in memory

33
Examples
  • who wc -l
  • ps wc -l
  • cat wordlist tr a A
  • who tee temp
  • who sort temp

34
Feedback
  • rm
  • ls -l new
  • more chap135
  • rm .o
  • ls ???
  • ls a-z
  • ls a

35
Metacharacter suppression
  • Metacharacter is computer nurdese for the word
    special
  • Single quotes
  • suppress the special meaning of all special
    characters (Keeps the shell from interpreting
    them)
  • Double Quotes
  • suppress all except \, and

36
Examples
  • cat homework
  • cat myvar
  • cat myvar
  • cat /class/n01/myfile
  • cat /class/n01/myfile

37
Command Substitution
  • One more metacharacter that the shell interprets
  • the backquote () used in pairs
  • tells the shell to treat the letters between the
    backquotes as a command and to execute it first
  • example
  • wc ls

38
Bonus UNIX HUMOR
  • From the UNIX HATERS GUIDE
  • Two of the most famous products of Berkeley are
    LSD and UNIX. I dont think that is a coincidence
  • Unix Programmers have a criminally lax attitude
    toward error reporting and checking

39
Comment on Unix mail program
  • Im rather surprised that the author of sendmail
    is still walking around alive
  • One of the recommended books for learning
    sendmail (Costales, et al from OReilly) has a
    bat on the cover. There are several reasons why
    people think this is appropriate

40

Why does the Costales book have a bat on the cover
  • Both bats and sendmail are held in low esteem
    by the general public
  • bats require magical rituals involving crosses
    and garlic to get them to do what you want to do.
    So does sendmail

41
UNIX ERROR MESSAGES
  • rm clinton-ethics
  • rm clinton-ethics non existent
  • How would you match Dan Quayles incompetence
  • unmatched
  • man why did you get a divorce
  • man too many arguments

42
Unix Error Messages
  • What is saccharine?
  • Bad substitute
  • drink
  • bottle cannot open
  • opener not found
  • got a light?
  • No match

43
Unix Error Messages
  • (where is jimmy hoffa
  • Missing )
  • touch me
  • chmod 000 me
  • touch me
  • touch cannot touch me permission denied
Write a Comment
User Comments (0)
About PowerShow.com