KIT213 Operating Systems Assignment Problem

Assignment Help Operating System
Reference no: EM132384329

KIT213 Operating Systems Semester 2, 2019
University of Tasmania
Assignment Two - UNIX Shell Programming

This is an individual assignment. There are three (3) shell programming tasks in this assignment. You are required to make a directory named kit213a2 under your home directory (on alacritas) and use kit213a2 as your working directory for this assignment.

Task A

Write a shell script (to run on the Bourne shell) that can be used to remove some old C programs you no longer wish to keep. When the script is run with no arguments supplied, it picks up each C program from the current directory and lists the first 10 lines (hint: research the head command). It then prompts for deletion of the file (the user can then choose to delete or not to delete the file). When the user supplies arguments (C program file names) with the script, it works on those files only.

Your script for this task must be named delC.sh. In designing your script you should consider the following scenarios:

• There is no C program file stored under the current directory;
• There is at least one C program file stored under the current directory;
• The user-supplied arguments list contains names of existing C programs stored under the current directory. We can assume that all the C programs have been correctly named as *.c, and that there is no special character (such as space) in any of these filenames;
• The user-supplied arguments list contains both existing and missing names of C programs stored under the current directory. Missing names refer to the files which no longer exist under the current directory.

Make sure your script is user-friendly and follows common sense (for example, when there is no C program stored under the current directory your script should display a message and then exit). The following is a sample output of the script. The $ is the shell prompt.

$ ./delC.sh
This script removes C files which you no longer want to keep. Here are the C file(s) under the current directory:
No C files found.

$ ./delC.sh
This script removes C files which you no longer want to keep. Here are the C file(s) under the current directory:
f1.c f2.c

Displaying first 10 lines of f1.c:

/* A C program for handling arrays Written by John Jones, July 2009 Updated April 2010
*/
#include <stdio.h> int main()
{
int x;

Delete file f1.c? (y/n):n (user input)
File f1.c NOT deleted.

Displaying first 10 lines of f2.c:

/* Another C program for handling arrays Written by John Jones, August 2009 Updated May 2010
*/
#include <stdio.h> int main()
{
int x, y, z;

Delete file f2.c? (y/n): y (user input)
File f2.c deleted.

$ ./delC.sh f1.c
This script removes C files which you no longer want to keep. The file(s) you want to delete is/are:
f1.c

Displaying first 10 lines of f1.c:

/* A C program for handling arrays Written by John Jones, July 2009 Updated April 2010
*/

Task B

Write a shell script (to run on the Bourne shell) that runs an infinite loop to monitor the creation and removal of .pdf or .PDF files under the current directory. Every 3 seconds it should display a list of those filenames created or removed after the previous display. Without loss of practical significance of this utility, we can assume that the time interval between creation of a .PDF or .pdf file and removal of a .PDF or .pdf file is over 3 seconds, which means that it's unnecessary for your script to handle the situation where creation of a file is followed by immediate removal of a file. (Hint: research the cmp and comm commands.)

Your script for this task must be named pdf.sh. The following is a sample output of the script (It is OK that the script leaves behind a temporary file when it is finally interrupted). The $ is the shell prompt.

$ ./pdf.sh

No pdf files have been created or removed in the last 3 seconds. No pdf files have been created or removed in the last 3 seconds.
The following pdf file(s) have been created in the last 3 seconds: a3.pdf
a4.pdf a5.pdf

The following pdf file(s) have been removed in the last 3 seconds: a4.pdf
a5.pdf

No pdf files have been created or removed in the last 3 seconds. No pdf files have been created or removed in the last 3 seconds.
... ... ... ... ...

Task C
Write a shell script (to run on the Bourne shell) that allows a user to view, add, or delete a setting in a configuration file (config.txt) that contains settings in the form variable=value. The following is an example of such configuration file:

HOME=/u/soc/abc
HOST=lawson
HOSTTYPE=sun4
LOGNAME=abc
OSTYPE=solaris
PATH=/usr/dt/bin:/usr/openwin/bin:/bin:.
PS1=$
PS2=> SHELL=/usr/bin/tcsh
TZ=Australia/Tasmania
USER=abc
VENDOR=sun
EDITOR=joe

Your script for this task must be named setting.sh. For ease of use, your script must present a menu of operations that a user may choose from. After the user makes a selection and that the selected operation has been completed, the menu must be displayed again so that the user can make another selection. Validation check on user inputs is required (see the following sample output about this). In the beginning of your script you need to check to see whether the required configuration file (config.txt) actually exists under the current directory (if not, your script displays a message and then exits).

Here is a sample output of your script. The $ is the shell prompt. The items in italics are not part of the sample output. They are hints indicating how your
script should behave.

$ ./setting.sh

*** MENU ***
1. Add a Setting
2. Delete a Setting
3. View a Setting
4. View All Settings Q - Quit

CHOICE: 1 (user input)
Enter setting (format: ABCD=abcd): (user simply presses the Enter/Return key)
New setting not entered

Enter setting (format: ABCD=abcd): EDITOR (user input)
Invalid setting (A valid setting needs to contain a "=" sign)

Enter setting (format: ABCD=abcd): EDITOR= (user input)
The variable name of the setting is: EDITOR The variable value of the setting is: Invalid setting.

(Hint: To retrieve a variable name before the "=" sign, research the expr command's ability in handling strings)

Enter setting (format: ABCD=abcd): =vi (user input)
The variable name of the setting is: The variable value of the setting is: vi Invalid setting.

Enter setting (format: ABCD=abcd): 1EDITOR=vi (user input)
The variable name of the setting is: 1EDITOR The variable value of the setting is: vi
Invalid setting. The first character of a variable name cannot be a digit.

Enter setting (format: ABCD=abcd): EDITOR=vi (user input)
The variable name of the setting is: EDITOR The variable value of the setting is: vi

New setting added.

*** MENU ***
1. Add a Setting
2. Delete a Setting
3. View a Setting
4. View All Settings Q - Quit
CHOICE: 1 (user input)

Enter setting (format: ABCD=abcd): USER=jchen (user input)
The variable name of the setting is: USER The variable value of the setting is: jchen
Variable exists. Changing the values of existing variables is not allowed.

*** MENU ***
1. Add a Setting
2. Delete a Setting
3. View a Setting
4. View All Settings Q - Quit
CHOICE: 2 (user input)

Enter variable name: EDTOR (user input)
Variable does not exist. (Your script needs to check whether a variable exists or not)

*** MENU ***
1. Add a Setting
2. Delete a Setting
3. View a Setting
4. View All Settings Q - Quit
CHOICE: 2 (user input)

Enter variable name: EDITOR (user input)
EDITOR=vi
Delete this setting (y/n)? y (user input)
Setting deleted (However, if user's answer is n here, then the setting stays)

*** MENU ***
1. Add a Setting
2. Delete a Setting
3. View a Setting
4. View All Settings Q - Quit
CHOICE: 3

Enter variable name:USER1 (user input)
Variable does not exist. (Your script needs to check whether a variable exists or not)

*** MENU ***
1. Add a Setting
2. Delete a Setting
3. View a Setting
4. View All Settings Q - Quit
CHOICE: 3 (user input)

Enter variable name: USER (user input)
USER=abc
Requested setting displayed above.

*** MENU ***
1. Add a Setting
2. Delete a Setting
3. View a Setting
4. View All Settings Q - Quit
CHOICE: 4 (user input)

HOME=/u/soc/abc HOST=lawson HOSTTYPE=sun4 LOGNAME=abc
OSTYPE=solaris PATH=/usr/dt/bin:/usr/openwin/bin:/bin:. PS1=$
PS2=>
SHELL=/usr/bin/tcsh TZ=Australia/Tasmania USER=abc
VENDOR=sun

*** MENU ***
1. Add a Setting
2. Delete a Setting
3. View a Setting
4. View All Settings Q - Quit
CHOICE: 5 (user input)
Invalid choice.

*** MENU ***
1. Add a Setting
2. Delete a Setting
3. View a Setting
4. View All Settings Q - quit
CHOICE: q (user input)
(The running script is terminated. The shell prompt is displayed)

Attachment:- UNIX Shell Programming.rar

Reference no: EM132384329

Questions Cloud

Hmgt400 research and data analysis in health care question : HMGT400 Research and Data Analysis in Health Care assignment help and assessment help, University of Maryland Global Campus - Run a logit model and use being a.
Design and implement multithreaded java applications : design and construct Java Graphical User Interfaces (GUI) that interact with problem domain objects - Design and implement multithreaded Java applications
What are your thoughts about the podcast : Listen to the Rough Translation Podcast (linked in Week 8) entitled Brazil in Black and White. What are your thoughts about this podcast?
ISY3001 e-Business Fundamentals and Systems Assignment : ISY3001 e-Business Fundamentals and Systems Assignment Help and Solutions-Australian Institute of Higher Education-Australia How does the website URL relate.
KIT213 Operating Systems Assignment Problem : KIT213 Operating Systems Assignment help and solution, University of Tasmania, Assessment help - UNIX Shell Programming - Write a shell script
What is the impact on stakeholders across the organization : During the implementation of a CIS (clinical information system ) what is the impact on stakeholders across the organization? How does it impact staff?
Compare juvenile delinquency prevention and treatment : Compare and contrast juvenile delinquency prevention and treatment. The paper should address the following: a description of delinquency prevention.
How texas incorporates treatment programs : For the mini-essay, I'd like for you to provide a reflective response to "how effective has Texas been in reducing recidivism among their juveniles."
Describing your thoughts about the course : Present 3 paragraphs describing your thoughts about the course ( High School Forensic Science). Some points to help guide your reflections.

Reviews

Write a Review

Operating System Questions & Answers

  What is the maximum data transfer rate

What is the storage capacity of the disk? What is the maximum data transfer rate (bytes/second)? What is the maximum rotational delay? What is the transfer time?

  Which os do you identify with and use on a regular basis

Operating systems (OSs) are the most important software on a computer. There are many different types of OSs. Which OS do you identify with and use on a regular

  What action and data protection controls

What action and data protection controls would you recommend sony use to provide better security for unreleased digital films and emails

  How it adds flexibility to the operating system

UNIX treats all devices as files. Explain why this is an innovative feature when it was first introduced and how it adds flexibility to the operating system

  When navigating through the packet capture

When navigating through the packet capture, why were there so many other TCP/UDP connections beyond the request for snhu edu?

  What is the maximum sustainable net data rate

When a 1024-bytes message is sent with AAL 3 / 4, what is the efficiency achieved? In other words, what fraction of the bits transmitted are useful data bits? Repeat for AAL 5.

  Explain features of vista operating system

What makes Vista better (or worse) choice for home or office computing? Explain general features of the operating system.

  Using international project management as a topic1 use

using international project management as a topic1. use three different search engines to obtain information.2. how do

  In a table forma compare between segmentation and virtual

in a table forma compare between segmentation and virtual memory organizations in terms of the memory structure

  Use of ntfs permissions for the folders or files on network

Justify the use of NTFS permissions for the folders / files on the network and explain the top two to three (2-3) reasons this is the most reliable option at the business unit leaders' disposal

  Explain how are two types of operating systems similar

What are the differences between a Windows operating system and a Linux operating system? What inherent security controls are included with each operating system? How are the two types of operating systems similar?

  Research an operating system or a programming language

Is the threading model based on kernel-level or user-level threads - What is the most significant advantage of the implementation and what is the most significant disadvantage of the implementation?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd