CENG 200 Lab 5: Forms, Regular Expressions, Intro to Shell Scripts

CENG 200 Lab 5: Forms, Regular Expressions, Intro to Shell Scripts

<p>Out: Oct 31, 2016 (group A – Mon) Nov 1, 2016 (group D - Tues)</p><p>Due: Nov 14, 2016 (group A: end of class – due to exam on Oct 31st) Nov 15, 2016 (group D: beginning of class)</p><p>CENG 200 Lab 5: Forms, Regular Expressions, Intro to Shell Scripts</p><p>This week’s assignment is intentionally light because of this past week’s midterm. Building a form will be critical when you are asked to connect a form to a Unix script. The assignment is marked out of 20. </p><p>Part I: Data Entry Form (7 marks)</p><p>Create a data form Lab5Form.html in using as many of the GUI elements described in Ch 16 of Castro or mentioned elsewhere. Different types of <input> tags will count as distinct input elements. Your form can't be a copy of formDemo.html nor should it be a copy of anyone else's form. To make it unique, design it around a theme. Add at least 1 image. When adding radio buttons make sure that you add at least two and make them mutually exclusive. (Similar forms will be checked for plagiarism, so don't copy the theme of someone else in the class.) Some suggested themes are:</p><p> a) Bank machine b) TV On-Screen Channel/Show selector c) College Course Enrollment d) Library Checkout e) Dating Service f) Work Order for Auto Repair g) Opinion Poll h) Fast Food Order Form</p><p>(1 mark for each unique type of form element. 7 recommended, but if you find more then bonus marks will apply –up to a limit of 15!)</p><p>Part II: Regular Expressions (8 marks)</p><p>^ matches the beginning of a line $ matches the end of a line</p><p>* matches any number of characters . matches a single character </p><p>\< matches the beginning of a word \> matches the end of a word</p><p>( ) is used to group expressions (expr1 | expre2) matches either expr1 or 2 ^ matches the beginning of a line $ matches the end of a line</p><p>[listOfChars] matches any chars in the list [^listOfChars] matches any char not in list</p><p>{n} matches exactly n copies of the preceding {n,} matches n or more copies of the preceding pattern pattern</p><p>{n,m} matches between n or m copies</p><p>There is a discussion on regular expressions at the start of Chapter 4 in the text. Use vim to test out any search expressions. Note the pattern used. Then use the egrep command on the file ~king/jargon.txt. When you are satisfied that you have the right pattern, add the -c option to egrep to count the final number of lines. Record the command and the # of lines matched a) Find all the lines that have the sequence of characters hacker in them. Modify this to find all the lines that contain the word hacker. b) Find all lines which have a six alphabetic character sequence that starts with b and ends with t. bookstore and bullet would be examples of matches. c) Find all the lines that contain a letter followed immediately by a number d) Find all the lines that end with the word Unix. e) Find all the empy lines – where the beginning of the line immediately follows the end. f) List all the lines that do not contain any vowels. Pipeline this through a 2nd egrep to eliminate all the empty lines. g) Find all references to the word privacy and output the 2 lines before and 3 lines after each reference. h) Apply the egrep command to the file /etc/passwd. Find all the entries that match people having either the same 1st or the same last name as you in one command. At the very least you should match one line – your own entry. </p><p>Your recorded answer should be in the form of a table:</p><p> vim expression egrep command count a) b) c) … Part III: Introduction to Shell Scripts (5 marks)</p><p>Write a shell script about.sh that takes as its argument a file name and gives a report on the file using the following format. You can use commands such as stat, type, wc, cut and finger to produce something that looks like: </p><p> a) File Name: myFile.txt (just echo out the argument) b) File Size: 210 bytes (use the wc command for this) c) File Type: ASCII text (use the file cmd for this) d) Last Accessed: 2010-06-18 18:21:03 (use the stat command and extract the date) e) File Owner: n123456 (John Smith) (the user id can be obtained from the ls command and the real name can be obtained from finger using a trick covered in class. Do NOT assume that you are the owner of the file, for example, try it out on ~king/Yankee.txt or one of the files in /usr or /usr/bin )</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    3 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us