This is an old revision of the document!
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 throwing numbers and math operations together to produce desired results (and in desired composition).
This week's project has 2 points of origin.
First, in the upf0/ sub-directory of the UNIX Public Directory, under a directory by the name of your username, there will be two files:
Copy these into your project directory.
The TASK file will contain the particular command-line equations you have to perform, along with their stated constraints.
The numbers.tgz file needs to be extracted, compiled, and installed; there are README and INSTALL files located within the archive with further instructions on how to do this.
Next, you will want to grab the latest version of the pipemath 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/INSTALL files).
Once those two steps are complete, you can begin on the tasks listed in your TASK file.
The numbers suite is basically a collection of command-line tools whose purpose is to display a single digit number, in accordance with the tools name.
For example, when you run the zero tool, a 0 is displayed to STDOUT. For one, a 1 is displayed to STDOUT. And so on up through nine.
You are to use these tools for producing the numbers needed for calculation, and only these tools.
The pipemath suite is a collection of command-line tools that perform various basic math operations you may fine useful for this project. The tools include:
With the exception of abs and sqrt, all the tools require two inputs (known as a binary operator; note, this is NOT saying you need to enter binary numbers into them… they expect decimal values). The first input MUST come from STDIN. The second input MUST come from the first command-line argument.
The tool, with the appropriate inputs, will perform the operation and output its result to STDOUT.
The abs, negate, and sqrt tools require only one input (known as a unary operator). That input must come from STDIN. When given an appropriate input, the operation is performed and will output its result to STDOUT.
In the TASK file, you will be given a set of tasks you need to construct command-lines for to solve, using the tools provided to you in both the numbers and pipemath suites. You will also want to make use of pipes and command expansions in your solutions.
There will also be both number, operation, minimum pipes, and maximum pipes constraints listed for each problem, which you will need to abide by in order to receive full credit. A * in any field indicates you are free to use any and all in that category.
There may be quantity limits on how many times you can use each number or operation. If so, such will be shown in parenthesis following the item in question.
As an example, take the following (formatted is it would appear in your TASK file):
task: 0 result: 4 numbers: three(2), five, seven, nine operations: * min_pipes: 2 max_pipes: *
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/upf0$ seven | minus `three` 4 lab46:~/src/unix/upf0$
BUT, we see that the min_pipes requirement is 2, and we only have 1 here… so we'll need to come up with another solution.
How about:
lab46:~/src/unix/upf0$ three | minus `seven` | negate 4 lab46:~/src/unix/upf0$
There we go… still got our 4, but this time via the minimum required quantity of pipes.
In this case, we'll want to record our command-line 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-line you ran, merely placed in a text file.
For example, if you cat the file, you should see the following:
lab46:~/src/unix/upf0$ cat task0.cli three | minus `seven` | negate lab46:~/src/unix/upf0$
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, upf0steps will contain the steps you took from the point of copying the numbers 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:
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 upf0steps file.
You should get some sort of confirmation indicating successful submission (actually, two) if all went according to plan. If not, check for typos and or locational mismatches.
I'll be looking for the following:
78:upf0:final tally of results (78/78) *:upf0:submitted result.txt file via submit tool [4/4] *:upf0:result.txt is correctly unscrambled and assembled [4/4] *:upf0:result.txt md5sum matches project MANIFEST [4/4] *:upf0:submitted pbx1steps file via submit tool [8/8] *:upf0:pbx1steps contains valid list of instructions [8/8] *:upf0:pbx1steps uses shell features [4/4] *:upf0:data file in public dir copied with absolute path [4/4] *:upf0:all other paths in pbx1steps are relative [4/4] *:upf0:if executed pbx1steps automates the project [8/8] *:upf0:project files commit and pushed to repository [4/4]