Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Reading assignments Upcoming.

Slides:



Advertisements
Similar presentations
A Guide to Unix Using Linux Fourth Edition
Advertisements

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.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Regular Expression Original Notes by Song Guo. What Regular Expressions Are Exactly - Terminology a regular expression is a pattern describing a certain.
CSET4100 – Fall 2009 Perl Introduction Scalar Data, Operators & Control Blocks Acknowledgements: Slides adapted from NYU Computer Science course on UNIX.
CS311 – Today's class Perl – Practical Extraction Report Language. Assignment 2 discussion Lecture 071CS Operating Systems I.
Guide To UNIX Using Linux Third Edition
JavaScript, Third 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.
Shell Scripting Awk (part1) Awk Programming Language standard unix language that is geared for text processing and creating formatted reports but it.
Regular Expression Darby Tien-Hao Chang (a.k.a. dirty) Department of Electrical Engineering, National Cheng Kung University.
Week Six Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Review midterm exam Break-out.
1 Operating Systems Lecture 3 Shell Scripts. 2 Shell Programming 1.Shell scripts must be marked as executable: chmod a+x myScript 2. Use # to start a.
1 Operating Systems Lecture 3 Shell Scripts. 2 Brief review of unix1.txt n Glob Construct (metacharacters) and other special characters F ?, *, [] F Ex.
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 Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Read.
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 Six Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Review midterm exam Break-out.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
Week Six Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Review midterm exam Upcoming.
Programming Languages Meeting 13 December 2/3, 2014.
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
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 Break-out problems Read.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
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 Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
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.
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.
Chapter 9: Perl Programming Practical Extraction and Report Language Some materials are taken from Sams Teach Yourself Perl 5 in 21 Days, Second Edition.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
Week Six Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming.
Introduction to Unix – CS 21
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Moving around in UNIX Break-Out Problems Upcoming.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Week Six Agenda Announcements Link of the week Midterm exam examples Review week four lab assignment This week’s expected outcomes Next lab assignment.
1 Introduction to Perl CIS*2450 Advanced Programming Techniques.
LIN Unix Lecture 7 Hana Filip. LIN Text Processing Command Line Utility Programs (cont.) sed LAST WEEK wc sort tr uniq awk TODAY join paste.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
CS 105 Perl: Basic I/O, Context, Strings, Lists Nathan Clement January 22, 2014.
Introduction to Perl October 4, 2004 Class Meeting 7 * Notes on Perl by Lenwood Heath, Virginia Tech © 2004.
Chapter Six Introduction to Shell Script Programming.
More Perl Data Types Scalar: it may be a number, a character string, or a reference to another data type. -the sigil $ is used to denote a scalar(or reference)
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 Six Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Review midterm exam Break-out.
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.
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.
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 Six Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Review midterm exam Break-out.
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.
 History  Ease of use  Portability  Standard  Security & Privacy  User support  Application &Popularity Today  Ten Most Popular Programming Languages.
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.
The Scripting Programming Language
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
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 Six Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Review midterm exam Break-out.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Looking for Patterns - Finding them with Regular Expressions
Week Six Agenda Announcements Link of the week
Week Five Agenda Announcements Link of the week
What is Bash Shell Scripting?
Presentation transcript:

Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Reading assignments Upcoming deadlines Lab assistance, questions and answers

Announcements Midterm exam Midterm Outline Mid-term outline available here: rm_Outline.doc rm_Outline.doc

Link of the week Data Disaster Ontrack Data Recovery Data Disaster Helpful Hints - Use dedicated circuits for your connection - Keep your computer cool and in a dry place - Use a UPS (Uninterrupted Power Supply) - Don’t assume that your data is permanently destroyed even if the situation looks bad - Secure your work area and devices

Link of the week Data Disaster Big and small company operations Backup services Trouble shooting Data recovery

Review week four lab assignment What is an object file? Object code is a representation of code generated by a compiler after it processes a programming language code file. It contains compact, pre-parsed code, often referred to as binaries that can be linked with other object files to generate a final executable.

Review week four lab assignment What is ELF? Executable and Linking Format (ELF) is a common standard file format for executables, object code, shared libraries, and core dumps.

Review week four lab assignment

8 Online Documentation There are some websites that have Perl documentation. The two biggest ones are: for modules

Review week four lab assignment Perl Syntax ;end of statement delimiter,comma for line continuation \nnew line (non-printable character) Perl Variable Syntax $ singular variables prefix (single value, number or prefix for plural variable (array) %prefix for plural variable (hash) $_ default variable

Review week four lab assignment Perl Syntax while ( … ) { Action statements } if ( …) { Action statements }

Review week four lab assignment Perl Syntax if ( … ) { Action statements } else { Action statements }

12 Review week four lab assignment Perl Syntax The Perl language does not support case or switch statements. The closest way to achieve case evaluations is as follows: if ( $condition_one ) { action_one (); } elsif ( $condition_two ) { action_two (); }... else { action_n (); }

Review week four lab assignment Relational Operators Numeric StringMeaning > gtGreater than >= geGreater than or equalto <ltLess than <=leLess than or equal to

Review week four lab assignment Equality Operators NumericString Meaning == eq Equal to != ne Not equal to  cmp Comparison with signed result The  or cmp operators return 1 if the left operand is less than the right operand, 0if they are equal, and +1 it the left operand is greater than the right.

15 Review week four lab assignment Three Types of for loops # Old style C for loops for (my $i = 0; $i < 10; $i++) { $array[$i] = $i; } # Iterating loops for my $i { print "$i\n"; } # Postfix for loops print "$_\n"

16 Review week four lab assignment Perl Syntax foreach $total (12,9,3,7) { # Sum each value in the list. $sum += $total; } foreach (-32,10,1,2,0,-1) { # Valid numbers are considered to be greater than zero # The default variable is utilized, if ( $_ > 0 ) { # Print each valid number on a single output line. print "$_\n"; }

Review week four lab assignment Definition: array Arrays are an ordered list of scalars, accessed by the scalar’s position in the list. Otherwise known as a collection of scalars. In Perl, a scalar means the simplest data type which was designed to hold only one thing like a number, a string or a reference. Elements in an array are accessed by using an index. Array indexes start with zero.

Review week four lab assignment Array and Variable Initialization Initialize an = (“rake”, “mower”, = (“Will”, “Ken”, “Hazel”, “Jay”); $count Unload array elements into variables: ($rake, $mower, $shovel)

Review week four lab assignment Array Data Structures array of arrays – Two-dimensional array or a = ( [ “Sam”, “Clide”, “Kim” ], [ “Melinda”, Terri”, “Sissy” ], [ “Fred”, “Omar”, “Vincent” ] ); print $names [1] [1];

Review week four lab assignment Definition :Hash (associative array) A hash is similar to an array only because it contains a number of scalars. A hash is different in the case where the element of a structure represents a pair – a key and a value. Whenever we refer to an element of a Perl hash structure, we mean a pair (key and value) which links a value to a key. We have access to the elements of a hash variable by a scalar key. Hash table is an unordered set of scalars, accessed by some string value that is associated with each scalar.

Review week four lab assignment Hash Initialization %student_ages = ("John", 43, "Paul", 25, "Marie", 22); %members = (John => "father", Paul => "son", Marie => "daughter"); The comma-arrow (=>) operator is used to initialize the %members hash variable in the second line of code. The left side of the comma- arrow operator is expected to be a simple string and therefore it is not necessary to be quoted.

Review week four lab assignment Hash Initialization (con’t) %all_groups = ( group_name1 => [ “Betty”, “Tom”, “Moe” ], group_name2 => [ “Ali”, “Marcia”, “Sis” ] ); $all_groups{group_name1} [3] = “Sam”; for $couple ( keys %all_groups ) { print }\n; }

Review week four lab assignment Hash Copy %school_ages = %student_ages Demonstrate: ~varneyg/hash_table.pl

Review week four lab assignment Hash Table Example %colormap=( “12” => “gray”, “19” => “black”, “30” => “red”,); %colormap = (“12”, “gray”, “19”, “black”, “30”, “red”);

Review week four 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. 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)

Review week four 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);

Review week four lab assignment Practice scripts under /tmp directory on cs.franklin.edu arry_sort.pl awksrc read_list.pl sum_list.pl hash_table.pl two_dim.pl week_four.pl

Weeks four and five expected outcomes Write Perl scripts, including variables, control flow, and regular expression syntax

Next lab assignment Regular Expressions Search programs - grep and findstr. Text language programs - sed and awk Text editors – vi and emacs Many other languages use regular expressions and may advertise a particular Perl version.

Next lab assignment Regular Expression Special Characters Open square bracket [ Backslash\ Caret^ Dollar sign$ Dot. Pipe symbol| Question mark? Asterisk* Plus sign+ Opening and closing round brackets( )

Next lab assignment Regular Expression (a.k.a. regex or regexp) Is a pattern that describes a certain amount of text. A basic regular expression could be the single character, e.g.: ‘a ‘ Jack is a guy. It will match the first occurrence in the string. If succeeding matches are desired, the regex engine must be instructed to do so.

Next lab assignment Character Classes match only one out of several characters, e.g.: [ae] and gr[ae]y The order of the characters inside a character class doesn’t matter. Shorthand Character Classes match single characters, e.g.: \d and \w and \s and \t Non-Printable Characters are special character sequence to put non-printable characters in your regular expression, e.g.: \t and \r and \n and \a and \e and \v Helpful link:

Next lab assignment Dot matches almost any character, except line break characters, e.g.: gr.y Anchors match a position. Match start of string^ Match end of a string$ Alternation is the regular expression equivalent of “or”. The search pattern bird | insect will first return “bird. The second match will be “insect”.

Next lab assignment names Bo Happy /01/1945 male Jane Smith /23/1978 female Razi Jake /26/2005 male There are tabs in two places in the above data. One tab is after the name and after the birth date.

Next lab assignment Without options, print the desired fields in any order. awk ‘{ print $1, $2, $3, $4 }’ names The –F option changes the field separator on the command line. The \t is an Escape Sequence for a horizontal tab. awk –F”\t” ‘{ print $1 }’ names Awk Script # Author: Gary Varney # Script name: awksrc # Command line awk -f awksrc test # Command line: awk -f awksrc /^$/ { print "This is a blank line." } /[0-9]+/ { print "That is an integer." } /[A-Za-z]+/ { print "This is a string." }

Next lab assignment makefile Lab Assignment Copy the test_build.sh script from ~varneyg/public_html/itec400/make_lab This script executes the make command which in turn executes the makefile Demonstrate ~varneyg/public_html/itec400/make_lab/test_build.sh View the test_build.sh script

Next lab assignment Programming Perl, Chapter 32 Standard Modules Define: Module Parsing the command line with Getopt::Std Example: listdir –l –n –a 10:00 bottom top Perl to capture the command line arguments Example: $ARGV[0] ‘-l’ $ARGV[1]‘-n’ $ARGV[2]‘-a’ $ARGV[3]’10:00’ $ARGV[4]‘bottom’ $ARGV[5]‘top’ Link for getopts example:

Getopts Example #!/usr/bin/perl # script is "./g" use Getopt::Std; %options=(); getopts("od:fF",\%options); # like the shell getopt, "d:" means d takes an argument print "-o $options{o}\n" if defined $options{o}; print "-d $options{d}\n" if defined $options{d}; print "-f $options{f}\n" if defined $options{f}; print "-F $options{F}\n" if defined $options{F}; print "Unprocessed by Getopt::Std:\n" if $ARGV[0]; foreach { print "$_\n"; } Trying it out: bash-2.05a$./g -o -d foo -o 1 –d foo

Reading assignments Reading Assignment Essential System Administration Chapters 1-3 Programming Perl Chapters1-4 Chapter 32 (review)

Upcoming deadlines Simple Perl Exercises, 4-1 is due Feb. 5. Makefile Exercise, 6-2 is due Feb 19. Programming Assignment 1, 6-1 is due Feb 26. Mid-term exam, 7-1 is Feb Mid-term outline available at: rm_Outline.doc rm_Outline.doc

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