User Tools

Site Tools


Sidebar

projects

uxi0 (due 20170826)
wcp1 (due 20170826)
adm0 (due 20170830)
wcp2 (due 20170902)
pbx0 (due 20170906)
wcp3 (due 20170909)
pbx1 (due 20170913)
wcp4 (due 20170916)
pbx2 (due 20170920)
wcp5 (due 20170923)
upf0 (due 20170927)
wcp6 (due 20170930)
wpa0 (due 20171004)
wcp7 (due 20171007)
usr0 (due 20171018)
pbx3 (BONUS) (due 20171018)
wcp8 (due 20171021)
usf0 (due 20171025)
wcp9 (due 20171028)
gfo0 (due 20171101)
wcpA (due 20171104)
wcpB (due 20171111)
icp0 (due 20171115)
wcpC (due 20171118)
haas:fall2017:unix:projects:upf1

Corning Community College

CSCS1730 UNIX/Linux Fundamentals

~~TOC~~

Project: UNIX PIPE FUN (upf1)

Errata

  • any bugfixes or project updates will be posted here

Objective

To continue to cultivate your problem solving skills, to practice your shell skills, and to demonstrate your basic scripting skills.

Background

Pipes and command expansions are important concepts and skills that you need to be familiar with as we proceed down the shell scripting rabbit hole.

This project has us playing with various examples that will require regular use of these skills, for the purpose of converting units.

Get started

This week's project has 2 points of origin.

First, in the upf1/ sub-directory of the UNIX Public Directory, under a directory by the name of your username, you will find the following file:

  • TASK

Copy this file into your project directory.

The TASK file will contain the particular units to start with and convert to.

Next, you will want to grab the latest version of the unittools suite from the following URL:

You will want to use a tool like wget(1) or curl(1) to non-interactively download it onto your lab46 account, and similarly extract, compile, and install that (check its own README file).

There may be multiple versions of unittools available at the download link. Unless you have specific reason otherwise (for this project, you do not), you want to go for the latest version, which will be reflected by the most recent datestamp encoded in the file's name.

For example, say you have the following:

  • unittools-20160731-10.tar.gz
  • unittools-20161024-14.tar.gz
  • unittools-20170123-13.tar.gz
  • unittools-20170201-09.tar.gz

You would select the “20170201-09” one, because the date it encodes (Feb 1st, 2017 at 9am) is the most recent in that group. You will find this to be a common practice with many software projects on the internet.

Once those two steps are complete, you can begin on the tasks listed in your TASK file.

unittools suite

The unittools suite is a collection of command-line tools that perform various unit conversions you may find useful for this project. The tools include:

  • cm2in - convert centimeters to inches
  • cu2mm - convert cubits to millimeters
  • dm2cm - convert decimeters to centimeters
  • Dm2mi - convert Decameters to miles
  • ft2hm - convert feet to hectometers
  • ft2yd - convert feet to yards
  • hm2dm - convert hectometers to decimeters
  • hm2Dm - convert hectometers to Decameters
  • in2cu - convert inches to cubits
  • in2ft - convert inches to feet
  • km2ft - convert kilometers to feet
  • mi2km - convert miles to kilometers
  • mi2yd - convert miles to yards
  • mm2dm - convert millimeters to decimeters
  • st2mi - convert stadions to miles
  • yd2mi - convert yards to miles
  • yd2st - convert yards to stadions

The tools by default expect input via STDIN, and will output to STDOUT.

These tools have command-line arguments which can alter their default behavior. You may want to review the options and defaults.

Process

In the TASK file, you will be given a set of source quantities/units and destination units you need to construct command-lines for to solve, using the tools provided to you in the unittools suite. You will also want to make use of pipes and command expansions in your solutions.

As an example, take the following (formatted is it would appear in your TASK file):

task: 0
precision: 3
input_value: 35
input_unit: cm
output_unit: ft
chain_delim: " >> "

With these in mind, we can set about solving this problem, using the tools in combination to arrive at the desired result.

A potential solution would be as follows:

lab46:~/src/unix/upf1$ echo "35" | cm2in
13.78 in
lab46:~/src/unix/upf1$ echo "13.78" | in2ft
1.15 ft
lab46:~/src/unix/upf1$ 

Note that with precision, you need to instruct the tools to display out to the specified number of decimal places.

We'll want to record our command-lines in the appropriate place. Since this is task #0, we'll want to record it in a file called: task0.cli, which should basically just contain the command-lines you ran, merely placed in a text file.

For final output, we'll want to display the chain of conversions we went through. So, for this above example:

lab46:~/src/unix/upf1$ ./task0.cli
35.000cm >> 13.780in >> 1.148ft
lab46:~/src/unix/upf1$ 

Basically, each task#.cli can be its own script. If we were to execute it, the correct result should be produced.

upf1steps

You will once again be creating a steps file that can automate your project.

As in previous projects, upf1steps will contain the steps you took from the point of copying the numbers suite and downloading the unittools suite up until the submit step (hint: just run the task#.cli scripts within the steps script).

  • To clarify: YES, I want to see steps creating a project directory, copying and downloading files in question, extracting, compiling, installing, and then of course running each individual task#.cli script.

There are some additional constraints you need to keep in mind:

  • your script should not produce ANY STDERR output
  • your script should ONLY produce STDOUT output in conformance with the below stated requirements. Any other output needs to be silenced.
  • For each task, you'll want to display things as follows:
    • “Task X conversion chain: CHAIN”
      • where X is the task number (0, 1, 2, etc.)
      • where CHAIN is the conversion chain output matching the TASK file result requested (ie, you must run your task#.cli script to produce this output).
        • note that the task#.cli output appears on the SAME line as the “Task X conversion chain:” text, and there is a single space separating it from the colon.
        • note there is no space between value and unit

For example, a sample output of your upf1steps script should appear like follows (but your # values will of course be different based on your individual TASK file):

lab46:~/src/unix/upf1$ ./upf1steps
Task 0 conversion chain: 35.000cm >> 13.780in >> 1.148ft
...
lab46:~/src/unix/upf1$ 

Submission

By successfully performing this project, you should have a set of task#.cli files (one for each task). You will want to submit these, along with a upf1steps file.

To submit this project to me using the submit tool, run the following command at your lab46 prompt:

$ submit unix upf1 upf1steps task*.cli
Submitting unix project "upf1":
    -> upf1steps(OK)
    -> task0.cli(OK)
    -> task1.cli(OK)
    -> task2.cli(OK)
    -> task3.cli(OK)
       ...

SUCCESSFULLY SUBMITTED

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

I'll be looking for the following:

78:upf1:final tally of results (78/78)
*:upf1:upf1steps submitted via submit tool [2/2]
*:upf1:upf1steps covers steps from copy until submit [4/4]
*:upf1:upf1steps squelches any STDERR output [4/4]
*:upf1:upf1steps only displays required STDOUT output [4/4]
*:upf1:task0.cli produces correct result [2/2]
*:upf1:task0.cli uses specified input_value [1/1]
*:upf1:task0.cli uses specified input_unit [1/1]
*:upf1:task0.cli solution in specified output_unit [2/2]
*:upf1:task0.cli solution using specified precision [1/1]
*:upf1:task0.cli solution using specified delimiter [1/1]
*:upf1:task1.cli produces correct result [2/2]
*:upf1:task1.cli uses specified input_value [1/1]
*:upf1:task1.cli uses specified input_unit [1/1]
*:upf1:task1.cli solution in specified output_unit [2/2]
*:upf1:task1.cli solution using specified precision [1/1]
*:upf1:task1.cli solution using specified delimiter [1/1]
*:upf1:task2.cli produces correct result [2/2]
*:upf1:task2.cli uses specified input_value [1/1]
*:upf1:task2.cli uses specified input_unit [1/1]
*:upf1:task2.cli solution in specified output_unit [2/2]
*:upf1:task2.cli solution using specified precision [1/1]
*:upf1:task2.cli solution using specified delimiter [1/1]
*:upf1:task3.cli produces correct result [2/2]
*:upf1:task3.cli uses specified input_value [1/1]
*:upf1:task3.cli uses specified input_unit [1/1]
*:upf1:task3.cli solution in specified output_unit [2/2]
*:upf1:task3.cli solution using specified precision [1/1]
*:upf1:task3.cli solution using specified delimiter [1/1]
*:upf1:task4.cli produces correct result [2/2]
*:upf1:task4.cli uses specified input_value [1/1]
*:upf1:task4.cli uses specified input_unit [1/1]
*:upf1:task4.cli solution in specified output_unit [2/2]
*:upf1:task4.cli solution using specified precision [1/1]
*:upf1:task4.cli solution using specified delimiter [1/1]
*:upf1:task5.cli produces correct result [2/2]
*:upf1:task5.cli uses specified input_value [1/1]
*:upf1:task5.cli uses specified input_unit [1/1]
*:upf1:task5.cli solution in specified output_unit [2/2]
*:upf1:task5.cli solution using specified precision [1/1]
*:upf1:task5.cli solution using specified delimiter [1/1]
*:upf1:task6.cli produces correct result [2/2]
*:upf1:task6.cli uses specified input_value [1/1]
*:upf1:task6.cli uses specified input_unit [1/1]
*:upf1:task6.cli solution in specified output_unit [2/2]
*:upf1:task6.cli solution using specified precision [1/1]
*:upf1:task6.cli solution using specified delimiter [1/1]
*:upf1:task7.cli produces correct result [2/2]
*:upf1:task7.cli uses specified input_value [1/1]
*:upf1:task7.cli uses specified input_unit [1/1]
*:upf1:task7.cli solution in specified output_unit [2/2]
*:upf1:task7.cli solution using specified precision [1/1]
*:upf1:task7.cli solution using specified delimiter [1/1]
haas/fall2017/unix/projects/upf1.txt · Last modified: 2017/03/05 23:31 by 127.0.0.1