Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.

Slides:



Advertisements
Similar presentations
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
Advertisements

A Guide to Unix Using Linux Fourth Edition
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
CS311 – Today's class Perl – Practical Extraction Report Language. Assignment 2 discussion Lecture 071CS Operating Systems I.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
CS 497C – Introduction to UNIX Lecture 33: - Shell Programming Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Shell Programming 1. Understanding Unix shell programming language: A. It has features of high-level languages. B. Convenient to do the programming. C.
Bash Shell Scripting 10 Second Guide Common environment variables PATH - Sets the search path for any executable command. Similar to the PATH variable.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Shell Script Examples.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Review week two lab assignment This week’s expected outcomes Next lab assignment.
Advanced File Processing
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Upcoming deadlines Lab.
Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.
Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Read.
Linux+ Guide to Linux Certification, Third Edition
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Reading assignments Upcoming.
Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Read.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Week Six Agenda Announcements (in-class question) Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Review.
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.
Introduction to Perl Yupu Liang cbio at MSKCC
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.
Perl Language Yize Chen CS354. History Perl was designed by Larry Wall in 1987 as a text processing language Perl has revised several times and becomes.
Perl: Lecture 1 The language. What Perl is Merger of Unix tools – Very popular under UNIX – shell, sed, awk Programming language – C syntax Scripting.
Lecture 24CS311 – Operating Systems 1 1 CS311 – Lecture 24 Outline Final Exam Study Guide Note: These lecture notes are not intended replace your notes.
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.
Introduction to Unix – CS 21
Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Moving around in UNIX Break-Out Problems Upcoming.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
(A Very Short) Introduction to Shell Scripts CSCI N321 – System and Network Administration Copyright © 2000, 2003 by Scott Orr and the Trustees of Indiana.
LIN Unix Lecture 5 Unix Shell Scripts. LIN Command Coordination ; && || command1 ; command2 Interpretation: Do command 1. Then do command.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Use of the Virtual Machine Review week two lab assignment This week’s expected.
CSCI 330 UNIX and Network Programming Unit IX: Shell Scripts.
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.
Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Use of the Virtual Machine Review week two lab assignment This week’s expected.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Moving around in UNIX Break-Out Problems Upcoming.
Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems Upcoming.
Week Five Agenda Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines.
Week Four Agenda Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines.
Sed. Class Issues vSphere Issues – root only until lab 3.
Linux+ Guide to Linux Certification, Second Edition
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Moving around in UNIX Break-Out Problems Upcoming.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
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.
ITEC400 Week Five Robert D’Andrea. Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Moving around.
Linux Administration Working with the BASH Shell.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Week Three Agenda Link of the Week Review Week Two Information
Sydney Opera House.
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
ITEC400 Week Three Professor Robert D’Andrea
Week Five Agenda Announcements Link of the week
Week Three Agenda Link of the Week Review Week Two Information
Tutorial of Unix Command & shell scriptS 5027
UNIX Reference Sheets CSE 2031 Fall 2010.
Linux Shell Script Programming
Introduction to Bash Programming, part 3
Review.
Presentation transcript:

Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines Lab assistance, questions and answers

Announcements Script Comments Scripts should contain the following comments: Editing Author: Script Functionality: Lab Assignment: Due Date:

Link of the Week Object Code code-and-object-codehttps://freedom-to-tinker.com/blog/felten/source- code-and-object-code What is object code? Object File Format

Link of the Week

Review Week Three Lab Assignment What is a filter? A UNIX filter command performs an operation or manipulation of the input text from a file. Standard in and out are typically used during this operation. UNIX Command Line Filters awk, cat, cut, expand, compress, fold, grep, head, nl, perl, pr, sed, sh, sort, split, strings, tail, tac, tee, tr, uniq, and wc

Review Week Three Lab Assignment File System Filters cat, cd, chmod, chown, chgrp, cksum, cmp, cp, dd, du, df, fsck, fuser, ln, ls, lsattr, lsof, mkdir, mount, mv, pwd, rm, rmdir, split, touch, umask Processes Filters at, chroot, cron, exit, kill, killall, nice, pgrep, pidof, pkill, ps, pstree, sleep, time, top, and wait

Review Week Three Lab Assignment Test Command A common way to set up a condition for the if command is with the test command. test condition or [ condition ] The test command evaluates the condition and returns 0 or 1, depending on the results of the test. The brackets work exactly like the test condition. The open bracket is a link to test.

Review Week Three Lab Assignment Constructing Conditions -s file-r file-w file -S file -x file-f file-d file Examples: if [ ! –f /etc/quotatab ] Does the plain file named /etc/quotatab not exist? If [ -d /etc/rc0.d ] Is the /etc/rc0.d name a directory?

Review Week Three Lab Assignment Constructing Conditions -s file = True if the file exists and its size is greater than zero. -s file = True if the file exists and is a socket. -w file = True if the file exists and is writable. -x file = True if the file exists and is executable. -f file = True if the file exists and is a regular file -d file = True if the file exists and is a directory.

Review Week Three Lab Assignment Perl is a simple language that compiles and executes like a shell or batch type file. Perl doesn’t impose special growth limitations on an array or data strings Perl is a composite of C, AWK, and Basic. Perl was originally developed to manipulate text information.

Review Week Three Lab Assignment Perl’s capabilities range from - System administration - Web development - Network programming - GUI development Perl’s major features are -Procedural Programming makes use of simple sequential steps, routines, subroutines, and methods. -Object Oriented Programming (OOP) makes use of “objects”. The key elements of are inheritance, modularity, polymorphism, and encapsulation.

Review Week Three Lab Assignment Perl and Shell Similarities Perl ~ Shell $# Perl $ARGV[0] ~ Shell $1 Perl $ARGV[1] ~ Shell $2 Perl ~ Shell if [ $# != 2] All Perl statements are terminated with a “;” Perl exit 0 is returned if execution was successful. Perl exit 1 is returned if execution fails.

Review Week Three Lab Assignment Perl syntax $? - this variable contains the return value # - precedes a comment statement in Perl \n - new line syntax “ …” $strexp = “This text is considered as a string”; ‘ …’ $charexp = ‘a’; ` …` $cmdexp = `ls – array containing command line arguments $_ - default implied scalar

Review Week Three Lab Assignment There are two types of relational operators. One class operates on numeric values, the other on string values. Relational operators Numeric String Meaning > gt Greater than >= ge Greater than or equal < lt Less than <=le Less than or equal

Review Week Three Lab Assignment Equality Operators Numeric String Meaning == eq Equal to != ne Not equal to  cmp Comparison, sign results -1 if the left operand is less than right operand 0 If both operands equal to right operand 1 If the left operand is greater right operand

Review Week Three Lab Assignment Equality Operators if ( $count != 5 ) { print "The counter is NOT equal to 5.\n"; } if ( $response eq 'YES‘ ) { print "You said YES"; } else { print "I don't know what you said, but it wasn't YES"; }

Review Week Three Lab Assignment Commands cal –y (display a calendar for the year) cal –j 2010 (display Julian dates) cal –m 2010 (display Monday first day) cal –s 2010 (display Sunday first day) cal (display September 2010 month)

Review Week Three Lab Assignment Umask Calculation umask setting = 027 Complement of umask = 750 File default permission setting = 666 Directory default permission setting = 777 The resultant permissions are calculated via bitwise AND of the unary complement of the argument (using bitwise NOT) and the permissions specified by the program.

Week Four Expected Outcomes Learning Outcomes Write Perl scripts, including variables, control flow, and regular expression syntax

Next Lab Assignment Perl is designed to - Process text data - Perform pattern matching - Utilize string handling tasks Perl is available on many platforms - UNIX - Linux - HP-UX

Next Lab Assignment Perl utilizes two types of categories Singular variables that represent a single- value. The variable prefix symbol for a scalar is the $. Plural variables are ones that contain multiple-values. Arrays and hashes are two multi-valued variables. The variable prefix symbol for an array and hash and %, respectively.

Next Lab Assignment Perl data types $answer = 42; (an integer) $pi = ; (a “real” number) $animal = “horse”; (string) $statement = “I exercise my $animal”; (string with interpolation) $amount = ‘It cost me $5.00’; (string without interpolation) $cwd = `pwd`; (string output from a command)

Next Lab Assignment Initialize Perl array: Definition: An array is an ordered list of scalars, accessed by the scalar’s position in the = (“car”, “mower”, = (“Will”, “Karim”, “Asma”, “Jay”); $count Extecute Perl script:./week_four.pl

Next Lab Assignment Open Statement The open function can be used to create file handles for different purposes (input, output, and piping), you need to be able to specify which behavior you want. When you open a data file in Perl, all you have to do is specify (a) a file handle and (b) the name of the file you want to read from. open (CHECKBOOK, "checkbook.txt");

Next Lab Assignment open functions open(file_handler, “file_name”) open(file_handler, “<file_name”) open (file_handler, “>file_name”) open (file_handler, “>>file_name”) See page 21 in your Perl text.

Next Lab Assignment Filehandle is utilized for both input and output files. Most file names are cryptic and are meaningless to programmers. The purpose of a filehandle is to help the programmer remember a simple file name throughout a program. A filehandle is a name given for a file, device, socket, or pipe. Filehandle command line format: open(filehandle, file name, permissions, chmod); Example: open($FH,$file_name);

Next Lab Assignment If you want to read text from a file line-by-line, then use the following syntax: = ; The operator - where FILE is a previously opened filehandle - returns all the unread lines of the text file in list context or a single line in scalar context. Hence, if you had a particularly large file and you wanted to conserve memory you could process it line by line: while ( ) { print $_; }

Next Lab Assignment Perl Formats if ( … ) { … } while ( … ) { … }

Next Lab Assignment Perl Formats for ( initialize variable, test variable, increment variable) { … }

Next Lab Assignment Perl Formats if ($append) { open(MYOUTFILE, ">filename.out"); #open for write, overwrite } else { open(MYOUTFILE, ">> filename.out"); #open for write, append }

Next Lab Assignment What is List = (6 - 4, 4 * 4, 8 / 2, 9 - 8); while ( … ) { … }

Next Lab Assignment Perl's for loop, or for statement, is used to loop through a designated block of code until a specific condition is met. What is List = (6 - 4, 4 * 4, 8 / 2, 9 - 8); while ( … ) { … }

Next Lab Assignment What is a “for” loop? for (counter = 0; counter < 10; counter++) { … } Three expressions are contained in a for loop: 1. Set initial state of the loop variable 2. Condition test the loop variable 3. Modify the state of the loop variable

Next Lab Assignment Foreach Statement Format foreach VAR (List) { … } Read a list of values Execute Perl script:./read_list.pl

Next Lab Assignment Foreach Statement = ('Larry', 'Curly', 'Moe'); foreach { print $_; } Sum the elements in an array Execute Perl script:./sum_list.pl

Next Lab Assignment Display the content of an array Execute Perl script:./array_display.pl Sort the elements in an array Execute Perl script:./array_sort.pl

Next Lab Assignment Regular Expressions Definition: Regular expression provides a concise and flexible means for "matching" (specifying and recognizing) strings of text, such as particular characters, words, or patterns of characters. Abbreviations for "regular expression" include "regex" and "regexp". The concept of regular expressions was first popularized by utilities provided by Unix distributions, in particular the editor “ed” and the command/filter grep. Example: if ( /UNIX V5/ ) { print “UNIX V5 found on system. \n”; }

Next Lab Assignment Regular Expressions Substitution operator: s/original value/new value/ Character class: Matches a single character that is contained within the brackets [ a-zA-Z0-9_ ] Special or meta characters are used to denote actions or delimit groups: + means “one or more of whatever was before the + symbol”. Matches any single character (i.e., x.z) ^ Matches the starting position within the string $ Matches the ending position of the string or the position just before a string-ending newline

Next Lab Assignment Regular Expressions

Next lab assignment Perl Program Statement #!/usr/bin/perl #!/usr/bin/perl -w Print continuation statement print "error: incorrect number of arguments", "\n", "usage: intlist a b (where a < b)", "\n"; Execute Perl scripts:./linenum.pl and./intlist.pl

Break-out problems $strexp = “This text is considered as a string”; $intexp = 10; $floatptexp = 2.54; $charexp = ‘a’; $cmdexp = `ls –l`; $argexp = (“two”, “four”, = (“Jackie”, “Vicki”, “Alex”); $array [0] = “new value”; $a = $b + 5; $container ($map{blue}, $map{orange}, $map{jade}) = (0xff0000, 0x00ff00, 0x0000ff0);

Next Lab Assignment Programming Perl text book reading Chapter One Chapter Two Chapter Three

Upcoming deadlines Lab Assignment 3-1 is due on October 6, Lab Assignment 4-1 is due on October 13, 2013

Questions and answers Questions Comments Concerns After class, I will help students with their scripts.