User Tools

Site Tools


haas:spring2019:unix:projects:spf1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
haas:spring2019:unix:projects:spf1 [2019/04/16 16:03] – [script1: pigen] wedgehaas:spring2019:unix:projects:spf1 [2019/04/18 18:41] (current) – [Objective] wedge
Line 10: Line 10:
   * any bugfixes or project updates will be posted here   * any bugfixes or project updates will be posted here
  
-=====Toolbox===== 
-In addition to the tools you're already familiar with, it is recommended you check out the following tools for possible application in this project (you may not need to use them in your solution, but they definitely offer up functionality that some solutions can make use of): 
- 
-  * **basename(1)** 
-  * **bc(1)** 
-  * **cut(1)** 
-  * **diff(1)** 
-  * **grep(1)** 
-  * **mktemp(1)** 
-  * **sed(1)** 
-  * **tr(1)** 
-  * **wc(1)** 
  
 =====Objective===== =====Objective=====
Line 30: Line 18:
   * an initialization script   * an initialization script
   * an incrementing 8-bit binary counter (0-255)   * an incrementing 8-bit binary counter (0-255)
-  * a decreminting 8-bit binary counter (255-0)+  * a decrementing 8-bit binary counter (255-0)
   * a strobing light sequence (back and forth)   * a strobing light sequence (back and forth)
  
Line 56: Line 44:
  
 <cli> <cli>
-lab46:~$ ssh pi@pi1b_0#+lab46:~$ ssh pi@pi1b_0X
 </cli> </cli>
  
Line 169: Line 157:
 ====script4: strobe/flash display==== ====script4: strobe/flash display====
 The purpose of this script is to create a fancy flashing pattern, lighting up and turning off the LEDs to create wavy or "back and forth" style visual effects. The purpose of this script is to create a fancy flashing pattern, lighting up and turning off the LEDs to create wavy or "back and forth" style visual effects.
-====script2: pigrep==== 
-Your second script will be called **pigrep** (no extension, although it is to be a bash script, with proper shabang, comments, and solution), and will perform searches on a **pigen**-generated **pi.#.out** file for specified patterns (numerical substrings) within the generated digits. 
  
-By default, if you run the script by itself, it should generate the following error (and exit with a non-zero value): 
- 
-<cli> 
-lab46:~/src/unix/spf0$ ./pigrep 
-ERROR: must specify PATTERN 
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-It will have online usage information, displayed when the 'help' option is provided anywhere on the **pigrep** command-line: 
- 
-<cli> 
-lab46:~/src/unix/spf0$ ./pigrep help 
- 
- pigrep - search available pi digits via regex for matches; 
-          must be part of pipeline (send PI digits in via STDIN) 
- 
-   usage: pigrep [OPTION...] PATTERN 
- 
-    note: if MAX variable is set, cap processing at that value 
- 
- options: 
- 
-  atend - calculations are based on last digit of match 
- byline - output one value per line (default is space-separated) 
-  drop3 - do not include leading 3 of pi (*3*14) in processing 
- offset - determine offsets of matches (from start of digits) 
-   help - display this help and exit 
- 
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-Your script should also take the following arguments (in this order): 
- 
-  * required argument: 
-    * **PATTERN**: a string containing the numeric pattern you are looking for. 
-      * for example: '76' 
-  * optional arguments: 
-    * **atend**: by default, offset calculations are based on the first (left-most) digit of the pattern; with this option, compute the offset based on the last (right-most) digit of the pattern 
-      * **atend** is meant to be used in conjunction with **offset**, by itself it does not alter default processing 
-    * **byline**: by default, matches are space-separated. With this option, display one match per line 
-    * **drop3**: do not include the leading 3 of PI in processing 
-    * **offset**: determine offsets of matches from start of digits 
-    * **help**: display usage information 
- 
-You are also to check for the existence of a MAX variable, and if set to a valid, positive non-zero decimal (base 10) number, will cap the amount of results it processes / outputs. 
- 
-Numerical arguments are to be given as valid, positive non-zero decimal (base 10) values. 
- 
-With any of these arguments validly provided, they should adjust the script's processing and output accordingly. 
- 
-Also to keep in mind: 
- 
-  * Your script is not to produce any files as a result of operating. 
-    * If your solution calls for ANY temporary files, they need to be created in (and subsequently removed from) the **/tmp** directory, and be of a relatively unique name autogenerated by the **mktemp(1)** tool.  
- 
-Some sample outputs follow: 
- 
- 
- 
-====Only specifying numeric pattern==== 
-In the event only a pattern is provided, search through the PI data for the provided pattern, displaying each match to STDOUT. 
- 
-For example: 
- 
-<cli> 
-lab46:~/src/unix/spf0$ cat pi.120.out | ./pigrep '26' 
-26 26  
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-====one result per line==== 
-Using the **byline** option, instead of displaying results horizonally, they'll be displayed vertically (one result per line) to STDOUT. 
- 
-<cli> 
-lab46:~/src/unix/spf0$ cat pi.120.out | ./pigrep '26' byline 
-26  
-26  
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-====compute offsets from start of digits==== 
-The **offset** argument will, instead of displaying the numeric matches (which, aside from counting are of dubious value) will display how many digits away from the start of the PI digits the pattern resides. 
- 
-<cli> 
-lab46:~/src/unix/spf0$ cat pi.120.out | ./pigrep '26' offset 
-7 22  
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-With an example like this, we should easily be able to verify its correctness: 
- 
-<cli> 
-lab46:~/src/unix/spf0$ cat pi.120.out 
-314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 
-lab46:~/src/unix/spf0$ cat pi.120.out | cut -c7-8,22-23 
-2626 
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-====mixing options (offset, byline)==== 
-And we can mix options (in any order): 
- 
-<cli> 
-lab46:~/src/unix/spf0$ cat pi.120.out | ./pigrep byline '26' offset  
- 
-22  
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-====Using atend with offset==== 
-The **atend** option, issued by itself, has no impact on operations: 
- 
-<cli> 
-lab46:~/src/unix/spf0$ cat pi.120.out | ./pigrep atend '26'         
-26 26  
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-So we need to combine it with the **offset** option to make an impact: 
- 
-<cli> 
-lab46:~/src/unix/spf0$ cat pi.120.out | ./pigrep atend offset '26'  
-8 23  
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-====dropping the leading 3==== 
-With the **drop3** option, we merely exclude the leading 3 of pi from our calculations. This should result in everything being "off by one" from previous outputs (with any combination of arguments): 
- 
-<cli> 
-lab46:~/src/unix/spf0$ cat pi.120.out | ./pigrep atend offset '26' drop3 
-7 22  
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-====Using MAX to limit processing==== 
-Sometimes, a pattern may produce an untenable quantity of results. We may wish to restrict it, and can do so with the aid of setting the **MAX** variable. 
- 
-Take this request, which produces numerous results: 
- 
-<cli> 
-lab46:~/src/unix/spf0$ cat pi.120.out | ./pigrep '2'                     
-2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-We can cut that down to a smaller quantity by setting MAX accordingly (let's say, limit to 4 matches): 
- 
-<cli> 
-lab46:~/src/unix/spf0$ cat pi.120.out | MAX=4 ./pigrep '2' 
-2 2 2 2  
-lab46:~/src/unix/spf0$  
-</cli> 
- 
-You could also **export** MAX, mitigating the need to manually specify it for each run. 
 =====Specifications===== =====Specifications=====
-Evaluation will be based on correctness of values as well as on formatting/spacing. +Evaluation will be based on correctness of values as well as on commenting/formatting/indentation/spacing of scripts.
- +
-You'll notice that everything lines up and is positioned similarly:+
  
   * groupwork! This project is specifically designed to be performed in groups.   * groupwork! This project is specifically designed to be performed in groups.
     * I want to see groups ranging from a minimum of 2 people, to a maximum of 4 people. Any less and any more are not allowed.     * I want to see groups ranging from a minimum of 2 people, to a maximum of 4 people. Any less and any more are not allowed.
 +    * There are 4 pi's, 1 per table. There are 11 total people in the class, and on average 9 people regularly showing up; this could mean three groups of three (for example).
     * EVERY group member needs to be identified in your scripts (in a comment listing everyone).     * EVERY group member needs to be identified in your scripts (in a comment listing everyone).
 +    * ONE GROUP PER TABLE (no group should share a pi with another).
     * EVERY group member needs to be familiar with the end products     * EVERY group member needs to be familiar with the end products
     * EVERY group member needs to submit a copy of the scripts (they should all be identical- I will check)     * EVERY group member needs to submit a copy of the scripts (they should all be identical- I will check)
       * in the event you feel other group members have not lived up to their obligations, you may alter your scripts accordingly (be it not giving them the final product, or enhancing functionality to bring it in compliance, or leaving comments indicating who wasn't pulling their own weight).       * in the event you feel other group members have not lived up to their obligations, you may alter your scripts accordingly (be it not giving them the final product, or enhancing functionality to bring it in compliance, or leaving comments indicating who wasn't pulling their own weight).
     * EVERY group member needs to do an approximately equal portion of the work. Slackers should be called out (I'll be keeping an eye out as well) and they will lose credit.     * EVERY group member needs to do an approximately equal portion of the work. Slackers should be called out (I'll be keeping an eye out as well) and they will lose credit.
 +    * EACH group member is responsible for prolifically commenting and demonstrating functionality of ONE of the scripts. The commenter should be identified at the top of the particular script. No one person should be commenting all the scripts.
     * This project is designed to be done DURING class time. It may offer up some useful insights into other projects (that you're doing on your own).     * This project is designed to be done DURING class time. It may offer up some useful insights into other projects (that you're doing on your own).
-  * You need to check your arguments to ensure they are present and valid. +  * You need to check your arguments to ensure if they are present and valid. 
-    * all mentioned arguments implementing their indicated functionality (atend, byline, drop3, offset, help) +    * all mentioned arguments implementing their indicated functionality 
-      * help takes priority over other options +    * any invalid arguments or operating modes should generate an error and the script terminating (ie if the 'starting' number is the letter 'g').
-      * **atend** has no appreciable impact unless **offset** is also specified +
-    * any invalid arguments should be silently dropped/ignored.+
   * your script needs to commence with a proper **shabang** to run using bash; your script needs to end with an "**exit 0**" at the very end   * your script needs to commence with a proper **shabang** to run using bash; your script needs to end with an "**exit 0**" at the very end
   * comments and indentation are required and necessary   * comments and indentation are required and necessary
     * comments should explain how or why you are doing something     * comments should explain how or why you are doing something
     * indentation should be consistent throughout the script (no mixing of different indentation units; no mixing of tabs and spaces)     * indentation should be consistent throughout the script (no mixing of different indentation units; no mixing of tabs and spaces)
-    * indentation is to be no less than 3 on-screen spaces (I recommend tabstops of 4).+    * indentation is to be no less than 3 on-screen spaces (I recommend tabstops/shiftwidths of 4).
   * continuing with our shell scripting, your scripts will need to employ in a core/central way (note that both scripts may not each need all of these, but across both scripts, you should make sure that each of these concepts is utilized):   * continuing with our shell scripting, your scripts will need to employ in a core/central way (note that both scripts may not each need all of these, but across both scripts, you should make sure that each of these concepts is utilized):
     * variables     * variables
     * command-line argument parsing and usage     * command-line argument parsing and usage
-    * command-line pipelines 
-    * command expansions 
-    * regular expressions 
     * conditional/selection structures     * conditional/selection structures
     * loops     * loops
 +    * if appropriate: 
 +      * command-line pipelines
 +      * command expansions
 +      * regular expressions
   * your logic needs to:   * your logic needs to:
     * flow (one thing leads into the next, as best as possible)     * flow (one thing leads into the next, as best as possible)
Line 391: Line 222:
  
 This can be in the form of comments in your script, or even a separate file submitted at time of submission (if a file, be sure to make mention of it in your script so I can be sure to look for it). This can be in the form of comments in your script, or even a separate file submitted at time of submission (if a file, be sure to make mention of it in your script so I can be sure to look for it).
- 
  
 =====Submission===== =====Submission=====
-By successfully performing this project, you should have a fully functioning set of scripts by the names **pigen** and **pigrep**, which are all you need to submit for project completion (no steps file, as your "steps" file ARE the scripts you wrote).+By successfully performing this project, you should have a fully functioning set of scripts by the names **script1** through **script4** (possibly lacking **script3** if you've merged functionality with **script2**), which are all you need to submit for project completion (no steps file, as your "steps" file ARE the scripts you wrote).
  
 To submit this project to me using the **submit** tool, run the following command at your lab46 prompt: To submit this project to me using the **submit** tool, run the following command at your lab46 prompt:
  
 <cli> <cli>
-$ submit unix spf0 pigen pigrep +$ submit unix spf1 script1 script2 script3 script4 
-Submitting unix project "spf0": +Submitting unix project "spf1": 
-    -> pigen(OK) +    -> script1(OK) 
-    -> pigrep(OK)+    -> script2(OK) 
 +    -> script3(OK) 
 +    -> script4(OK)
  
 SUCCESSFULLY SUBMITTED SUCCESSFULLY SUBMITTED
Line 412: Line 244:
  
 <code> <code>
-26:spf0:final tally of results (26/26+52:spf1:final tally of results (52/52
-*:spf0:scripts effectively utilize variables in operations [2/2+*:spf1:scripts submitted in accordance with specifications [4/4
-*:spf0:scripts effectively utilize command-line arguments [2/2+*:spf1:initialization script logic present and functions [4/4
-*:spf0:scripts effectively utilize command expansions [2/2+*:spf1:initialization logic uses loop to automate task [4/4
-*:spf0:scripts effectively utilize regular expressions [2/2+*:spf1:incrementation script logic present and functions [4/4
-*:spf0:scripts effectively utilize selection structures [2/2+*:spf1:counter script logic is centrally based on loop [4/4
-*:spf0:scripts effectively utilize looping structures [2/2+*:spf1:counter script logic does adequate error checking [4/4
-*:spf0:scripts are proper bash scripts with shabang and exit [2/2+*:spf1:decrementation script logic present and functions [4/4
-*:spf0:pigrep displays values in proper orientation [2/2+*:spf1:flashy script logic present and functions [4/4
-*:spf0:pigrep accurately displays values as requested [2/2+*:spf1:scripts appropriately call the initialization logic [4/4
-*:spf0:scripts properly manage input violations [2/2+*:spf1:scripts are organized and easy to read [4/4
-*:spf0:pigen operates according to specifications [2/2+*:spf1:scripts effectively utilize selection structures [4/4
-*:spf0:pigrep operates according to specifications [2/2+*:spf1:scripts effectively utilize looping structures [4/4
-*:spf0:script logic is organized and easy to read [2/2]+*:spf1:scripts are proper bash scripts with shabang and exit [4/4]
 </code> </code>
  
haas/spring2019/unix/projects/spf1.1555430602.txt.gz · Last modified: 2019/04/16 16:03 by wedge