Abc Assignment Help

CSI6204 Scripting Languages: Portfolio Task 2 Assessment Answer

Scripting Languages: Portfolio Task 2

Overview

In this assignment you are required to write four (4) scripts that will demonstrate the extent to which you have understood the shell scripting concepts and practices addressed in Modules 5 to 8 inclusive. Each task is worth five (5) marks for a total assignment value of 20 marks. These portfolio tasks will help you build capacity for implementing the final main assessment.

GENERAL REQUIREMENTS

  • Your script will be marked on a standard Linux installation using the bash shell.
  • You must only use bash shell script as covered in lectures and workshops.
  • Refrain from using non-core commands, tools and utilities in your bash shell scripts. Non-standard bash commands, tools and utilities will not be downloaded and installed by your tutor.
  • Ensure each script you write is fully self-contained and is not configured to be dependent on external files, libraries or resources to run.
  • Do not use the trap command in any of your scripts.
  • Each script you submit must contain your full name and student number at the beginning as code comments.

IMPORTANT NOTES:

  • This is an individual assignment only and must not be completed in collaboration with other students
  • You may not work with others, acquire code from others, or provide code to others
  • Further, you may not post any of the assignment tasks below to a code-development community of any kind seeking solutions or advice
  • Nor may you copy and paste or otherwise reproduce code provided by external sources and use it as part of your own solutions
  • Where it is found that any of these restrictions have been ignored, academic misconduct proceedings may be initiated
  • Please read the checklist below and watch the associated video BEFORE submitting your assignment

Task 1 (5 marks)

Write a script that checks each value contained within a text file and determines whether it is comprised of:

  1. Letters only (A-z)
  2. Numbers only (0-9)
  3. A mix of letters and numbers, e.g. 123abc

Requirements

  • Call the script procval.sh
  • Read the values from a file named values.txt into an array named VALUES
  • Then use a c-style loop to check each value in the array to determine its status according to the criteria above, and for each, echo one of the following outputs to the terminal:
  • [ARRAY_VALUE] is comprised of numbers only
  • [ARRAY_VALUE] is comprised of letters only
  • [ARRAY_VALUE] is comprised of numbers and letters
  • …where [ARRAY_VALUE] represents each actual value in the array
  • The values.txt file does not include any values that do not meet one of these three (3) criteria above
  • To assist you in writing this script, a file named values.txt has been supplied with sample values provided. Please note that your tutor will use a file with the same name and structure as the values.txt file provided, but containing different data. Do not therefore hard-code any of the values within the values.txt file provided.
  • When your tutor marks your script, the values.txt file used will be located in the same directory as your script when marked. There is no need therefore to prompt for the location of values.txt as part of your script.

Task 2 (5 marks)

Write a script that retrieves the following information about a file:

  1. Its size in kilobytes
  2. The number of words it contains
  3. The date/time it was last modified

Requirements

  • Call the script fscheck.sh
  • All code involved in retrieving this information from a specified file is to be contained within a function named getprop()
  • Your script will prompt the user for a file name to check, which will then be handed to the getprop() function, i.e. getprop [file_name]
  • The getprop() function’s output is to be a message to terminal that states “The file [file_name] contains [word_count] words and is [file_size]K in size and was last modified [last_modified_date]
  • The last modified date is to be formatted as dd-mm-yy hh-mm-ss, e.g. 16-07-2020 09:59:44
  • Position the getprop() function within the fscheck.sh file and not in a separate file
  • When your tutor runs your script, a file containing standard textual content will be used (could be any file type – do not hard-code). The file the tutor uses will be located in the same directory as your script so there is no need to account for the file’s path.

Task 3 (5 marks)

Write a script that uses grepsed and awk in combination to extract specific information from a .html file and echo it to the terminal as a formatted summary.

Requirements

  • Call the script genrep.sh
  • The script will extract the required data from the file named attacks.html
  • The output of the script is to display each attack type and the total number of such attacks that took place in a given three (3) month period (see image below):

  • Use piping to keep the lines of code required to achieve the outcome to a minimum
  • You will be graded on your use of grepsed and awk to achieve the required outcome, so refrain from using other methods to achieve the result, e.g. using an IFS read within a for or while loop, for which no marks will be awarded
  • To assist you in writing this script, an attacks.html file (in a .zip folder) has been supplied with sample values. Please note that your tutor will use a file with the same name and structure as the attacks.html file provided, but containing different data. Do not therefore hard-code any of the values within the attacks.html file provided.
  • When your tutor marks your script, the attacks.html file used will be located in the same directory as your script when marked. There is no need therefore to prompt for the location of attacks.html as part of your script.

Task 4 (5 marks)

Write a script that uses awk exclusively to check all user passwords in a text file to ensure they meet the following password strength rules:

  1. Must be eight (8) or more characters in length
  2. Must contain at least one (1) number
  3. Must contain at least one (1) uppercase letter

Requirements

  • Call the script checkpw.sh
  • The script will check all passwords in a file named usrpwords.txt
  • The output of the script is to display each password with a message that states whether or not it meets password strength requirements (see image below):

 script checkpw.sh

  • The first line of the usrpwords.txt file contains header information and must be skipped
  • You will be graded on your use of awk to achieve the required outcome, so refrain from using any other means by which to achieve the result for which no marks will be awarded
  • To assist you in writing this script, a usrpwords.txt file has been supplied with sample values. Please note that your tutor will use a file with the same name and structure as the usrpwords.txt file provided, but containing different data. Do not therefore hard-code any of the values within the usrpwords.txt file provided.
  • When your tutor marks your script, the usrpwords.txt file used will be located in the same directory as your script when marked. There is no need therefore to prompt for the location of usrpwords.txt as part of your script.

Answer

Connect with online professionals for complete solutions. 

Customer Testimonials