We can work on Systems Scripting Bash scripting. Task 1 Write an interactive bash script with three functions that accepts two integer parameters. The script should request a user to input two numbers.

Systems Scripting

Bash scripting.

Task 1

Write an interactive bash script with three functions that accepts two integer parameters. The script should request a user to input two numbers. The first function should implement a multiplication. The second function should implement an addition. In the third function, when the second parameter is a multiple of 5, a multiplication operation should be executed otherwise the addition operation. The script should terminate after four interactions. Properly comment your code.

[7 marks]

Task 2

Write a bash script to open a file for writing. Then list all the running processes on the system and sort them alphabetically. Write the output result of the sorted process list into the opened file and close it. Furthermore, open this file in reading mode. Read and output the list of processes belonging to the logged on user to the terminal. In a further step, count the number of processes belonging to the logged on user from the file and output to the terminal. Close the file at the end of reading it. The script should work for every logged on user. That is no hardcoding of username. Properly comment your code.

[8 marks] Task 3

Write a bash script that automates the creation and deletion of user accounts. The script should accept as input argument, a file containing a list of user names to be created on the system. Enforce that the user provides this input file while executing the script. The script should check if the usernames already exist on the system before creating the accounts. If a user account exit, the script should notify the user and skip that user name to the next one. Make sure to create a home directory as well. When the input list has been exhausted and all the user account created, output the content of “/etc/passwd” file and “/home” directory to the terminal for verification. In a next step, the script should ask if user wants to delete the newly created accounts? If yes, the script should delete the accounts including their home directories and output again the content of “/etc/passwd” file and “/home” directory for verification. If no, the script should terminate with appropriate message. This script is to be tested/executed as a root user. Properly comment your code.

 

[10 marks]

 

Instruction:

 

Each task should be solved with a different script file.

Is this question part of your Assignment?

We can help

Our aim is to help you get A+ grades on your Coursework.

We handle assignments in a multiplicity of subject areas including Admission Essays, General Essays, Case Studies, Coursework, Dissertations, Editing, Research Papers, and Research proposals

Header Button Label: Get Started NowGet Started Header Button Label: View writing samplesView writing samples