1 / 34

Week Two Agenda

Week Two Agenda. Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments Announcements Break Out Problems Upcoming Deadlines Lab assistance, questions and chat time. Announcements. Class participation

thuong
Download Presentation

Week Two Agenda

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments Announcements Break Out Problems Upcoming Deadlines Lab assistance, questions and chat time

  2. Announcements Class participation Class participation is crucial in all courses. There are times when a student’s final grade borderlines the next highest grade. Every term this problem occurs. The instructors discretion about the students participation in class, normally is the determining factor if the final grade. Convince me professionally, that you want an “A” in this course.

  3. Link of the week • http://dmoz.org/Computers/Software/Operating_Systems • Definition of Operating System (OS) • Basic tasks performed by an operating system • Control and allocate memory • Prioritize system requests • Control input and output devices • Facilitate networking and management file systems

  4. Link of the week Services an Operating System (OS) perform • Process management • Memory management OS coordinates various types of memory • File systems • Networking • Graphical user interface (GUI) and command line • Device drivers • Security • Internal management • External management

  5. Use of the Virtual Machine Knoppix features • Demonstrate how to ftp a file from Knoppix software to the cs.franklin.edu (Einstein) machine using VMware software Open two Konqueror windows Enter the ftp protocol sftp://dandrear@cs.franklin.edu/export/home/dandrear in one screen Open a Konsole screen and create a file to transfer to the cs.franklin.edu machine.

  6. Review week one lab assignment A major benefit of ksh is that it has an emacs-like and a vi—like interface with which to edit the current command line. Basic vi editor commands. vi test_file.txt o (insert text - alpha character) Input information into file. cw (change an entire word in a file) Esc key (exit insert mode) :wq! (save text entered in file) :q! (quit without saving changes)

  7. Review week one lab assignment less command q (terminates pagination) Enter or Return key (advance one line) Space bar (full screen refresh) Location of weekly Power Point presentations: http://cs.franklin.edu/~dandrear/itec400/Winter09_Franklin_Live File format: Week_Two_2_ppt.ppt Week_Two_2.pptx

  8. Review week one lab assignment if [ ] then Action statements fi while [ ] do Action statements done for file_name in * do Action statements done

  9. Review week one lab assignment #!/bin/ksh if [ $# -ne 1 ] # Verify that there is one command line argument. then Action statements exit elif [ $1 -le syntax] # Verify that the argument value is greater than zero then Action statements fi while [ $variable -gt 0 ] # Argument value must be greater than zero. do printf $variable if [ $variable -gt 1 ] # If the value doesn’t equal one, output a comma then Action statements fi VARIABLE=$(( $VARIABLE - 1)) done print

  10. Review week one lab assignment #!/bin/ksh # Verify that there is only one argument on the command line if [ $# syntax1 ] then echo "Error. Can only use 0 or 1 arguments." echo "Usage: maxlines.sh [directory]." exit 1 fi flag=1

  11. Review week one lab assignment # If the number of positional parameters is equal to zero search through # the current directory. No directory provided on the command line. Case #1 : ./maxlines.sh if [ syntax-eq 0 ] then for testfile in * # Loop through the entire directory (top to bottom) do if [ -f $variable ] # Test that the name is a file then linetest1=`wc -l < $variable` if [ $flag -eq 1 ] then startline=$linetest1 startfile=$testfile flag=2 fi

  12. Review week one lab assignment #The script executes the following code after the first pass if [ $startline -lt $linetest1 ] then startline=$linetest1 startfile=$testfile fi fi done echo "File $startfile has the most lines with $startline lines." exit 0 fi Case #2: ./maxlines.sh /bin

  13. Review week one lab assignment Current directory (maxlines.sh case #1) /~dandrear/itec400/homework printnum.sh maxlines.sh Different directory (maxlines.sh case #2) /bin cat chmod cp

  14. Review week one lab assignment man (uses the “less” command for pagination) ls –l ps ps -ef | cut –c1-9 cut –c 1-7 wc -l $# date exit 0 exit 1 NUMBER=$2 echo $NUMBER less

  15. Review week one lab assignment cp file1 file2 mv file1 file2 rm file_1 rmdir dir_1 clear head tail pipes who myArray[1]=$1 more ps –ef

  16. Review week one lab assignment grep find ls ls –a mkdir cd $1 $1, $2, $3 cat <file name> chmod <permission> <file name> mv <original file name> <new file name>

  17. Review week one lab assignment sleep <number of seconds> diff <file name> <file name> cd <directory> sort <file name> umask who who am i

  18. Weeks 2 and 3 expected outcomes Upon successful completion of this module, the student will be able to: • Create scripts using shell variables and program control flow. • Use man page system and find script tools. • Use redirection and pipes to combine scripts and executables.

  19. Next lab assignment The term “shell” gets its name from the UNIX system. Many systems on which the KormShell language is implemented are designed in a way that is similar to the UNIX system. One of the things that makes the UNIX system so flexible is its layered design. At the core is the hardware. The hardware is surrounded by system software that most users never interact with, called the kernel. The kernel is surrounded by programs (often called utilities) such as cat, date, and diff, that perform specific tasks. A program that provides easy access to these utilities by the user is called a shell.

  20. Next lab assignment A shell enables the user to interact with resources of the computer, such as programs, files, directories, and devices. An interactive shell acts as a command interpreter. In its role as a command interpreter, the shell is the interface between the user and the system. The user enters text commands to the shell, and the shell carries them out, usually by running programs.

  21. Next lab assignment Most shells can also be used as a programming language. Users can combine command sequences to create new programs. These programs are known as shell scripts. Shell scripts automate use of the shell as a command interpreter.

  22. Next lab assignmentConcentric Circle Relationship

  23. Next lab assignment drwxrwxrwx permissions (directory) -rwxrwxrwx permissions (file) exit Each command has a return value. 0 indicates normal exit 1 indicates failed exit The return value of a command can be used with conditional or iteration commands.

  24. Next lab assignment Users can connect the standard output of one command into the standard input of another command by using the pipeline operator (|). Demonstrate: ps -ef ps –ef | wc –l ps –ef | awk ‘{print $2}’ ps –ef | grepdandrear ls –l | cut –c1-3 who –b (time of last system boot) who –d (print dead processes) who –r (print current run level) .

  25. Next lab assignment A process associates a number with each file that it has opened. This number is called a file descriptor. When you log in, your first process has the following three open files connected to your terminal. Standard input: Filedescriptor 0 is open for reading. Standard output: File descriptor 1 is open for writing. Standard error: File descriptor 2 is open reading.

  26. Next lab assignment Linux command documentation is known as “man”. Each page is a self-contained document. The Manual sections are split into eight numbered sections: 1 General commands. 2 System calls 3 C library functions 4 Special files (usually devices, those found in /dev) and drivers. 5 File formats and conventions 6 Games and screensavers 7 Miscellaneous 8 System administration commands and daemons

  27. Next lab assignment The grep command searches the named input file(s)for lines containing a given pattern. Normally, each line found is reported to standard output. Demonstrate: grep text ~dandrear/Winter08_solutions/foobar grep pattern foobar_1 grep pattern * The find command lists all pathnames that are in each of the given directories. Demonstrate: find / -type d –print find ~dandrear –type d -print find . –print find / -name foobar

  28. Next lab assignment Redirect the standard output of a command to a file. date > /tmp/date_saved Redirect the standard input of a command so that it reads from a file instead of from your terminal. cat < ~dandrear/Winter09_solutions/test.txt Append the standard output of a command to a file. cat foobar_2 >> foobar_1

  29. Next lab assignment The coding and testing process • Code one small script function at a time. • Test that function before adding more code to the script. • Program coding is an iterative process (code,test,code,test,code,test, …).

  30. Break Out Problems • ps | wc –l • who | awk ‘{print $1}‘ | sort –u | wc –l • ps –ef | awk ‘{print $1}’ | sort –u | wc –l • sort –r names.txt • ps –ef | awk ‘{print $9, $1}’ • find /bin -name gzip • find /etc -name motd • > newfile • rmnewfile • date | cut –c12-19 • nohupgrep This ~dandrear/Winter09_solutions/report.txt & • cp test_data.txt ~dandrea/temp • mv test_data.txt ~dandrear/temp • printf $NUMBER

  31. Upcoming Deadlines • Simple Shell scripts, Lab Assignment 2-1 due 1/25/09. • Provide your proctor information by 1/18/09. • Verify that your login is correct on Einstein. • Configure your directory structure on Einstein to comply with course specifications. • Advanced Scripting, Lab Assignment 3-1 due 2/1/09.

  32. Lab assistance, questions and answers • Questions • Comments • Concerns • After class I will help students with their scripts.

More Related