DOC PREVIEW
UW CSE 303 - Lecture Notes

This preview shows page 1-2-3-4-5 out of 14 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

'&$%CSE 303:Concepts and Tools for Software DevelopmentDan GrossmanSpring 2005Lecture 2— Processes, Users, Shell Special Characters, EmacsDan Grossman CSE303 Spring 2005, Lecture 2 1'&$%Where are weIt’s like we starte d over using the c omputer from sc ratch.And all we can do is run dinky programs at the command-line.But we are learning a model (the system is files, processes, and users)and a powerful way to control it (the shell).If we get the model right, hopefully we can learn lots of details quickly.Today:• The rest of the model briefly: Processes and Users• More programs (ps, chmod, kill, ...)• Special shell characters (*, ~, ...)• Text e diting (particularly emacs)Dan Grossman CSE303 Spring 2005, Lecture 2 2'&$%Users• There is one file-system, one operating system, (often) one CPU,and multiple users.• whoami• ls -l and chmod (permissions), quota (limits)• /etc/passwd guides the login program:– Correct username and password– Home directory– Which shell to open (pass it the home directory)– The shell then takes ove r, with startup scripts (e.g., .cshrc).(ls -a)• one “superuser” a.k.a. root. (Change passwords, halt machine, ...)Dan Grossman CSE303 Spring 2005, Lecture 2 3'&$%Processes• A running program is called a process. An application (e.g.,emacs), may be running as 0, 1, or 57 processes at any time.• The shell runs a program by “launching a process” waiting for itto finish, and giving you your prompt back.– What you want for ls, but not for emacs.– &, jobs, fg, bg, kill– ps, top• A running shell is just a process that kills itself when interpretingthe exit command.• (Apologies for aggressive vocabulary, but we’re stuck w ith it fornow.)Dan Grossman CSE303 Spring 2005, Lecture 2 4'&$%That’s most of a running system• File-system, users, processes• The operating system manages these• Processes can do I/O, change files, launch other processes.• Other things: Input/Output devices (monitor, keyboard, network)• GUIs don’t change any of this, but they do hide it a bit.Now: Back to the shell...Dan Grossman CSE303 Spring 2005, Lecture 2 5'&$%Complicating the shellSo far, our view of the shell is the barest minimum:• builtins affect subsequent interpretations. New: source, alias• Otherwise, the first “word” is a program run with the other“words” passed as arguments.– Programs interpret arguments arbitrarily, but conventions exist.But you want (and tcsh has) so much more:• Filename metacharacters• Pipes and Redirections (redirecting I/O from and to files)• Command-line editing and history access• Shell and environment variables• Programming Constructs (ifs, loops, arrays, expressions, ...)All together, a very powerful feature set, but awfully unelegant.Dan Grossman CSE303 Spring 2005, Lecture 2 6'&$%Filename metacharactersMuch happens to a command-line to turn it into a “call program witharguments” (or “invoke builtin”).Certain characters can expand into (potentially) multiple filenames:• ~foo – home directory of user foo• ~ – current user’s home directory (same as ~$user or‘whoami‘).• * (by itse lf) – all files in current directory• * – match 0 or more filename characters• ? – match 1 filename character• [abc], [a-E], [^a], ... more matchingRemember, this happens before deciding what to pass to a program.Dan Grossman CSE303 Spring 2005, Lecture 2 7'&$%Filename metacharacters: why• Manually, you use them all the time to save typing.• In scripts, you use them for flexibility. Example: You do not knowwhat files will be in a directory, but you can still do: cat *(though a better script would skip directories).But what if it’s not what you want? Use quoting ("*") or esc aping(\*).The rules on what needs escaping where are very arcane.Dan Grossman CSE303 Spring 2005, Lecture 2 8'&$%Where are weFeatures of the tcsh “language”:1. builtins2. program execution3. filename expansion4. command-line editing and history5. shell and environment variables6. programming constructsBut file editing is too useful to put off... so a detour to emacs (whichshares some editing commands with tcsh)Dan Grossman CSE303 Spring 2005, Lecture 2 9'&$%What is emacs?A programmable, extensible text e ditor, with lots of goodies forprogrammers.Not a full-blown IDE.Much “heavier weight” than vi.Top-6 commands:• C-g• C-x C-f• C-x C-s, C-x C-w• C-x C-c• C-x b• C-k, C-w, C-y, ...Customizable with elisp (starting with your .emacs).Dan Grossman CSE303 Spring 2005, Lecture 2 10'&$%Putting it all together: JavaJava is a programming language; you can write and run programs invarious environments.The javac and java programs “compile” and “run” Java programsand emacs has a decent Java mode.So we c an write Java files in emacs, and use the shell to run theprogram and pass arguments.(The Java program takes the class whose main should be run as itsfirst argument and gives it the re maining arguments.)Dan Grossman CSE303 Spring 2005, Lecture 2 11'&$%History• The history builtin• The ! special character– !!, !n, !abc, ...– Can add, substitute, etc.This is really for fast manual use; not so useful in scripts.Dan Grossman CSE303 Spring 2005, Lecture 2 12'&$%Command-line editingNote: getting backspace to work in Reflection-XLots of control-characters for moving around and editing thecommand-line.They make no se nse in sc ripts.Gotcha: C-q is a strange one (stops displaying output until C-s, butinput does get executed).Good news: many of the control characters have the same m eaning inemacs (and tcsh has a vi “mode” too).Dan Grossman CSE303 Spring 2005, Lecture 2 13'&$%SummaryAs promised, we are flying through this stuff!• Your computing environment has files, processes, users, a shell,and programs (including emacs).• Lots of small programs for files, permissions, manuals, etc.• The shell has strange rules for interpreting command-lines. So far:– Filename expansion– History expansion• The shell has lots of ways to customize/automate. So far:– alias– source– run .cshrc when shell starts.Next: I/O Redirection, Shell ProgrammingDan Grossman CSE303 Spring 2005, Lecture 2


View Full Document

UW CSE 303 - Lecture Notes

Documents in this Course
Profiling

Profiling

11 pages

Profiling

Profiling

22 pages

Profiling

Profiling

11 pages

Testing

Testing

12 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?