Assignment Specification
1 - Summary Details
- Weight: 15%
- Intended Learning Outcomes (ILOs) assessed:
- 1. Apply industry standard techniques and skills to configure secure network infrastructure and operating system processes
- 2. Design functional addressing schemes for networks subject to operational constraints
- 3. Troubleshoot faults and configuration errors in networking infrastructure and operating system processes
- 4. Evaluate the tools and commands to generate and maintain secure data
2 - Introduction
This assignment requires you to apply what you have learned from the unit's practical classes to write a script to implement the task specified below. You must complete this assignment individually and pay careful attention to the section on plagiarism to ensure the work you submit is your own.
Please pay close attention to the section later in this document on plagiarism and academic misconduct. We treat these very seriously, and, if detected, it can lead to serious penalties.
The assignment task summary is to write a script to investigate specially-named files in a specific (user-provided) directory and display special characters on the screen according to the binary values found in each file. The result will be a character-based ("ASCII art") versions of famous images. The full task description is in section 6.
3 - Working Environment
Setting up and daily work
On the Unix teaching server (Tasmania students: ictteach.its.utas.edu.au , Melbourne students: 192.168.5.56), you must make a directory named kit501script in your home directory and use this directory as your working directory for all scripting assignment development. Assignment scripts must be edited in this directory - the server's login history may be used to confirm your personal ongoing development of the script (so fully-complete scripts that suddenly appear in your home directory may be a sign of potential academic misconduct activity).
- The first time you start working on the assignment, after logging on, type the following commands (
$
is the prompt, do not type that):$ mkdir kit501script
$ cd kit501script
- Every other time you log on, simply do the following and then continue working:
$ cd kit501script
You will be working with a script file that must be called displayAscii.sh. When executing your
script, the required syntax is:
$ ./displayAscii.sh directoryName imageName
where:
- directoryName – is the name of a directory containing special ASCII image files
- imageName - is the name of the image to display from the specified directory
Update: PuTTY users (i.e. students using Microsoft Windows) - you should adjust the default colour settings in the PuTTY application so that the displayed output is not reversed (negative images). This means you need to make PuTTY's default background colour white, and the foreground (text) colour black. Instructions are here: PuttyColours.pdf (pdf, 316.2KB)
4 - Syntax / Commands
What commands can you use?
All scripts must be completed using syntax and commands discussed in past (and some future) practical classes – no additional referential syntax (that is not discussed in practicals) is allowed. This means your script solutions must not use alternative constructs and syntax e.g. solutions found through websites via google searches that use commands and shell syntax that we have not covered in the practical content, and you must not use external parties, systems or other individuals to write the scripts for you (this is considered plagiarism and academic misconduct).
Non-permitted syntax
Part of your solution to the task described below requires converting from binary to decimal – you are not allowed to use the shell "builtin" binary conversion syntax to do this
e.g. echo $((2#101010101))
is not allowed.
This restriction also extends to any other command that has not been discussed in classes – the following list shows some of the common methods (but not all) found through a brief google search – none are permitted:awk sed printf xxd od perl ibase obase bc
Extensive and complex regular expressions are also prohibited (advanced pattern matching). If in doubt as to what syntax or commands may be used, ask your tutor or the lecturer. Novel or unusual commands and syntax is usually a good indication the assignment script was written by someone else.
5 - Assessment Process
All student script submissions will be marked on the Unix teaching servers using bash according to the rubric at the end of this specification. You will lose considerable marks if your scripts do not run correctly on the teaching servers, so it is imperative (and required) that you develop and test your scripts on the teaching servers before you submit.
Pay attention to the marking rubric
Pay close attention to the marking rubric shown at the end of this assignment specification. This scheme shows what you must (successfully) achieve to receive marks. The displayAscii.sh script must also have clear and tidy structure, appropriate indentation, whitespace, include appropriate comments, and have your identification details and the script's purpose specified in comments at the top of your script.
6 - The Assignment Task
Task Overview
In the early days of computing, output was limited in terminal display equipment to be line-based ASCII characters. In this assessment task, pretend you are working as a script developer for a company that wants to display photographs on line-based displays (like your macOS Terminal SSH connection or PC PuTTY connection to the teaching server).
The company has stored the photographs in a very inefficient manner. Instead of each photograph being stored in a file containing all of the ASCII characters to be displayed, each photograph has been broken up into (potentially) thousands of files, with each file containing only one binary value that represents a special ASCII character. Each file name itself contains the image name, followed by a row and column value that correspond to the position of where the file's converted binary value to ASCII symbol needs to be displayed.
Sometimes errors crept in during the photograph to storage file conversion process, so some files have invalid names, and sometimes the contents of a file does not contain a valid (or in range) binary value. The script you develop needs to be able to cope with, and report on, these errors as well as displaying the resulting image.
A displayed image will be a 2-dimensional matrix, with ASCII character positions specified by row then column (counting from zero). See the 3x3 image below for an example (most images are 40 columns wide or more however). The position of the "@" character would be specified in a filename that indicates row 2 column 1.
Column 0 | Column 1 | Column 2 | |
Row 0 | X | * | ^ |
Row 1 | $ | * | ^ |
Row 2 | # | @ | ! |
6.1 SHADECHAR and Grey Levels
Special variable - SHADECHAR
Each pixel in an original source image has previously been mapped to one of 80 levels of grey, and there is a mapping between each grey level and a standard ASCII character. This is implemented already for you in a special variable called SHADECHAR that contains 80 characters. The darkest level of grey is represented by the $ character (which is the first character in SHADECHAR), and pure white is represented by the space character (in fact the last 10 characters in SHADECHAR are spaces).
SHADECHAR='$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,"^`\'"'"'. '
Each binary value found in a valid file should be converted to decimal, and that decimal value then is used as an index into the SHADECHAR string. For example, the value 00001001 is 9 in decimal, and the 9th character in SHADECHAR is * (indexing from 0) – see the following table showing the first 11 (of 80) character values:
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ... |
SHADECHAR Value | $ | @ | B | % | 8 | & | W | M | # | * | o |
6.2 Files Provided
Template Script
A brief prototype/template script (called displayAscii.sh) is provided in the following directory on the teaching servers:
/units/kit501/assignment/sem2-2023
Copy displayAscii.sh to your kit501script working directory – this is a starting point for the script you will be editing and then submitting later as your assignment solution. Use the following command to create your own copy (assuming you have set up the working environment outlined in Section 3):
$ cp /units/kit501/assignment/sem2-2023/displayAscii.sh ~/kit501script
The prototype displayAscii.sh script contains several variable definitions for you to use – one is the SHADECHAR variable mentioned above, and the other variables contain special terminal control codes that can be used to provide coloured text, blinking text, and a new line when needed. For example, to make red (foreground) text on your screen, use the REDF variable value, followed by some text, then turn off the colour mode with the value of the NC (no colour) variable. This coloured text is required when pointing out errors in the image (described below). When this is needed will be described later.
e.g. echo -e -n "${REDF} This would be red text! ${NC}"
The same /units/kit501/assignment/sem2-2023 directory also contains some sample binary image files to help you test your script – they can be found in the examples and testing subdirectories.
Example image files
There are 1000s of files associated with 4 ASCII images in the /units/kit501/assignment/sem2-2023/examples directory. You do not need to copy these files (nor should you), but when testing your script, you can refer to them directly. There are 44 files in the /units/kit501/assignment/sem2-2023/testing directory - these are used to test for specified errors detailed below.
When your script is being assessed, the marker will be using their own test files.
6.3 Valid File Names
Image file name format
Every image that has been broken up into many files (one file per row and column position) that your script has to process has the following filename format:
imagename_xyz_ijk
where:
- imagename is the name of the original photo
- xyz and ijk are 3-digit (numeric) values that range between 000 to 999
e.g. einstein_012_038 is a valid filename (that would contain a binary value) for row 12 and column 38 (note the leading zeroes when the row or column value is less than 100).
6.4 Valid File Contents
Image file - valid binary values
Every validly-named file your script processes should contain a single valid 8-bit binary value (non-valid filenames do not need to be processed for their content):
Binary values must only contain 8 binary digits (0 and 1), and the converted decimal value can range from zero to 79. Other values would be considered invalid.
6.5 Displaying a valid binary value from a valid filename
Assuming a valid filename has been found, and it contains a valid binary value (between 0 and 79), then the associated character from SHADECHAR that matches the decimal value of the binary value would be displayed to the screen (in the correct row and column):
Putting it all together:
Column 0 | Column 1 | Column 2 | |
Row 0 | X | * | ^ |
Row 1 | $ | * | ^ |
Row 2 | # | @ | ! |
Referring back to the example in the Task Overview (shown again above), and assuming this is from an "image" called "example", to define it, there would be 9 files in a directory:
- Row 0: example_000_000, example_000_001, example_000_002
- Row 1: example_001_000, example_001_001, example_001_002
- Row 2: example_002_000, example_002_001, example_002_002
To focus on one file, the row 2 column 1 file, example_002_001, (which we want to display the "@" character from the SHADECHAR variable) would contain the binary value: 00000001 (which is 1 in decimal). This binary value is actually the index to be used for the SHADECHAR variable i.e. the single character at position/index 1 in SHADECHAR is @ i.e. in code, this would be ${SHADECHAR:1:1} (the extra 1 at the end here is the length/number of characters to use - this syntax is detailed in Practical 8).
To display the # character shown above, example_002_000 must contain 00001000 - can you see why?
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ... |
SHADECHAR Value | $ | @ | B | % | 8 | & | W | M | # | * | o |
6.6 Error Values
Invalid filenames and invalid binary values need to be discovered and reported by your script. The type of error is categorised depending on its value.
6.6.1 Invalid File Names
There are 5 categories of filename errors that can occur.
Filename Errors
If your script encounters an invalidly-named file, it has to report it at the end (after displaying the image). The categories are defined in the following table.
Category | Description | Example Testing Files |
ROWERROR1 | The filename contains an invalid row value (eg non-numeric digits) but has a valid column value Examples: image_0yz_000 einstein_00x_123 totoro_a_200 | test8 |
ROWERROR2 | The filename does not contain enough row digits but has a valid column value | test9 |
COLERROR1 | The filename contains an invalid column value eg non-numeric digits but has a valid row value Examples: image_217_aa0 einstein_100_xx totoro_097_20- | test6 |
COLERROR2 | The filename does not contain enough column digits but has a valid row value Examples: image_011_6 einstein_212_13 totoro_088_05 | test7 |
GENERALERR | The filename has an invalid name (i.e. all other errors) Examples: image_xyz_abc einstein_12a_13x totoro_1_1 | test10 |
The Example Testing Files column values above are the imagename part in the directory /units/kit501/assignment/sem2-2023/testing
You can use these testing image files to test your script as you're developing it to see if it correctly reports the type of error.
e.g $ ./displayAscii.sh /units/kit501/assignment/sem2-2023/testing test8
A correctly-functioning script would have the following output for the test8 example above:
*
GENERALERR: file test10_abc_def has an invalid name
Note the error category above is in order of decreasing priority, so if a filename has an invalid row value and an invalid column issue, only one error (the higher-priority, the row issue) is reported.
6.6.2 Invalid File Contents (Binary Values)
There are 4 categories of binary value errors - please see the following table. Your script should display a prominent X for the row/column position associated with the filename if an invalid binary value was found in the file:
Binary errors
Category | Description | Example Testing Files |
BINARYERROR1 |
The binary value contains any non-binary digits (numeric or otherwise). Examples: | test2 |
BINARYERROR2 | The binary value contains less than 8 binary digits Examples: 0000000 010101 1 | test3 |
BINARYERROR3 | The binary value contains more than 8 binary digits Examples: 010101010101 111111111 | test4 |
BINARYERROR4 | The binary value is too large (more than 79 in decimal) Examples: 01101111 10000000 01111111 | test5 |
You can use these example testing image files to test your script as you're developing it to see if it correctly reports the type of binary value error.
e.g $ ./displayAscii.sh /units/kit501/assignment/sem2-2023/testing test2
A correctly-functioning script would have the following output for the test2 example above:
X
BINARYERROR1: non-binary digit(s):badbinary found in test2_000_000