Linux Assignment Help, Homework Help, Shell Scripting Assignment, Homework Help

Create a Bash Shell script with the following functionality:

The task is to create a number of executable Hello-Name shell scripts based on user provided names.

Specification:

1. Prompt the user for the number of Hello-name scripts they wish to create.

2. Then for the specified number of files, prompt the user for a Name.

a. Using this specific name create a new Bash shell scripted named “Name.sh” with the usual Bash shell script start and a Hello Name message line. See sample output below.

b. Set the permission of the new Hello Name script to be executable.

c. Verify if the new “Hello-Name” script is executable.

d. Display appropriate messages if executable or not.

3. Then finally:

a. Display the contents of the last “Hello-Name” script created:

b. List the current directory’s shell script files in long format so that is show the permissions.

Sample Output:

Linux Assignment Help, Linux Homework Help

Arithmetic and Functions in Bash

Create a Bash script to display a menu, using a “while loop“, as follows to perform a number of calculations on a pair of user-provided numbers:

Please select an option:

  • Read in two new numbers.
  • Add the two numbers
  • Multiply the two numbers
  • Divide the bigger number by the smaller number
  • Quit

Select option:

Note:

  • Option 1 should prompt the user for two new numbers.
  • Option 2 should display the result of adding the two numbers.
  • Option 3 should display the result of multiplying the two numbers.
  • Option 4 should display the result of dividing the bigger number by the smaller number the two numbers. (make sure you check that the denominator is not equal to zero)
  • Option 5 stops the script

Each of these mathematical operations should be created as a function. If the user enters an invalid menu choice an error message should be displayed. It is important to demonstrate the correct execution of the script, showing all the options working.

Task Scheduling (Cron)

Step 1: Create a Bash script call testcron.sh which redirects and appends the system date to a .txt file in the /tmp directory.

Show a screen shot of your script.

Step 2: Create a cron schedule to run the testcron.sh script to be executed:

  • Every minute, for 10 minutes starting from the time you are testing your script to run today (the day your testing your script) and the day after next during the current month only

Step 3:

Provide: the crontab entry and Evidence that the task is running according to schedule (this can be accomplished by showing the contents of the text file in the /tmp folder and by examining the contents of the /var/log/syslog file).

Python Scripting

1. In a Linux environment create a Python script with a list of the following filenames:

[‘testfile1’, ‘testfile2’, ‘testfile3’, ‘testfile4’, ‘testfile5’]. Note: lower case.

2. Using a loop, iterate through the list, and for each item use a subprocess call to create an empty file with the name in upper-case (use the string method for case conversion)

3. Once the files have been created use subprocess calls to:

a) Show the current username

b) Current working directory

c) List directory contents to show the new files (long format).

d) System date and time

Regular Expressions in Python

Exercise

Using Regex, create a Python script to verify if a user entered string contains a correctly formatted ISBN number. If so then display and appropriate message, and each of the five elements (see below). If not then, display a correspondingly appropriate message.

Use a multiline regular expression for better legibility, with comments explaining each Regex section.

Sample running output:

ISBN Grouping information:

An ISBN is an International Standard Book Number. It consist of 13 digits. Each ISBN consists of 5 elements with each section being separated by spaces or hyphens. Three of the five elements may be of varying length:

1. Prefix element – currently this can only be either 978 or 979. It is always 3 digits in length

2. Registration group element – this identifies the particular country, geographical region, or language area participating in the ISBN system. This element may be between 1 and 5 digits in length

3. Registrant element – this identifies the particular publisher or imprint. This may be up to 7 digits in length

4. Publication element – this identifies the particular edition and format of a specific title. This may be up to 6 digits in length

5. Check digit – this is always the final single digit that mathematically validates the rest of the number.

Source: https://www.isbn-international

Awk

Exercise 9.

Provide screenshots of your AWK statements for this exercise. You must also show your scripts/awk statements running using screenshots.

  1. Create a text file called “Zoo.txt” with the following content (You can use VIM editor):

This file contains the number (“No”) of visitors visiting five Dublin Zoo enclosures, over a 4 day period.

Structure of the file

(EnclosureID, Animal, NoVisitorsDay1, NoVisitorsDay 2, NoVisitorsDay 3, NoVisitorsDay 4, Location, Genus)

Note: the use of “,” as the field separator and the first line is the header of the file (the header must be included in your file).

2. Write AWK statements that will calculate and display the following

a) The total number of visitors to the “Crocodile” enclosure over the four days.

b) List the Animal names and total count of the animals having more than 20 people visiting on Day3.

c) The average of the four day total of visitors to the five enclosures.

Sample output: The average number of visitors per enclosure over the four days is: 90.2

d) The number of enclosures with more than 30 people visiting Mammals on day4

PowerShell

Exercise 10.

Create a PowerShell script with the following functionality:

1) Prompt the user for a directory name. The script should then verify if the directory exists in the current path (use Get-Location to know the current path).

2) If the directory,

o exists, then display a message indicating that does

o does not exist, then indicate so and ask the user if he wants to create that directory. If the user agrees so, then create the directory.

3) Repeat the process (steps 1 and 2) until the user indicates the contrary (use a loop).

4) Finally, list the contents of the current directory.

Give a Comment