Corning Community College
CSCS1730 UNIX/Linux Fundamentals
~~TOC~~
To continue to cultivate your problem solving skills, to practice your shell skills, and to demonstrate your basic scripting skills.
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.
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:
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:
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.
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:
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.
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.
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).
There are some additional constraints you need to keep in mind:
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$
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]