Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
36 views19 pages

Raj Bhul EC3236 Programming Report PDF

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 19

Bachelor of Information Technology (Hons)

Assignment Cover Sheet

Course Code: EC3236 Course Title: System Programming


Assignment Title: Programming Report Due Date: 20th March 2024
Date Submitted: 20th March 2024 Lecturer Name: Nirdosh Bista

To be completed if this is an individual assignment


I declare that this assignment is my individual work. I have not worked collaboratively nor have I
copied from any other student’s work or from any other source except where due acknowledgement is
made explicitly in the text, nor has any part been written for me by another person .

Student Name: Raj Bhul Student ID: 00020691 Signature: ________________


To be completed if this is a group assignment
We declare that this is a group assignment and that no part of this submission has been copied from
any other student's work or from any other source except where due acknowledgement is made
explicitly in the text, nor has any part been written for us by another person.

Student ID Student Name Signature


_________ ________________________________________ __________
_________ ________________________________________ __________
_________ ________________________________________ __________
_________ ________________________________________ __________

Lecturer's comments: _______________________________________________________


_________________________________________________________________________
Total Marks: ______________ Lecturer's Signature: _________________
Feedback to Student:
I/We acknowledged receiving feedback from the lecturer on this assignment.
Student’s Signature: ____________ _____________ _____________ ___________

Extension certification:
This assignment has been given an extension and is now due on _______________.
Lecturer’s Signature: _____________

1
ACKNOWLEDGEMENT

I would like to express my sincere thanks to Padmashree College's Bachelor of Information


Technology department for giving me the chance to complete this assignment as part of my
academic program.

I sincerely thank Mr. Nirdosh Bista, my lecturer, for his continuous support, direction, and
attention to detail during the course of the assignment, all of which contributed to its
successful conclusion. Mr. Bista, in addition to his busy schedule, offered priceless advice,
helpful criticism and encouragement.

I also want to express thanks to all of the materials that helped me finish this task. The books,
research papers, websites, and software tools that I have used have been extremely helpful in
both deepening my understanding and making the execution of the task easier.

Lastly, I would like to express my gratitude to all individuals who directly or indirectly
contributed to the accomplishment of this assignment. Your support and assistance have been
invaluable, and I am truly grateful for your contributions.

Thank you all for your invaluable support and assistance during this assignment.

Table of Content
Introduction........................................................................................................................................4
Introduction to Each Scenario..........................................................................................................5
Snapshot of Each Script: Visualizing File Management Operations............................................7
Test Case and Output Screenshot..................................................................................................12

2
Conclusion........................................................................................................................................19
References.........................................................................................................................................20
Marking Scheme..............................................................................................................................21

Introduction

This assignment focuses on learning file management, a crucial skill in systems


programming. File handling is essential for effective work in this field. We'll be using bash
scripting to automate and simplify file tasks on Linux systems.

Understanding how to manage files efficiently is at the heart of this task. By learning file
management, we enhance our ability to navigate and manipulate data, which is vital for
systems programming. Bash scripting serves as our tool for automating tasks and making file
management processes smoother.

That means being able to do things like:

3
 Making tasks we do a lot easier by automating them.
 Handling files and folders without messing things up.
 Making sure the information we're giving the computer makes sense.
 Writing code that's easy for anyone to understand and use.

The script I'm making should be easy for anyone to use. It should let users do things like
making new folders, seeing what's inside a folder, creating empty files, writing stuff in files,
and deleting files or folders. I have to make sure it doesn't mess up and accidentally delete
something important, so I need to double-check everything.

To make the script, I'll need to make sure it asks the user questions in a simple way and
checks if the answers make sense. It's also important to add little notes in the script to explain
what each part does, so anyone reading it can understand. And when the user is done, the
script should close nicely without causing any problems.

Once I finish this assignment, I'll be much better at scripting in Bash. These skills will come
in handy in lots of jobs, like managing computer systems or making software. I'm excited to
complete this assignment and feel more confident about taking on similar tasks in the future.

Introduction to Each Scenario

The assignment at hand requires the development of a bash script designed to execute
fundamental file management tasks within a Linux environment. These tasks are crucial for a
range of professionals, spanning from system administrators to developers, and anyone who
regularly engages with files in Linux systems.

File Management Operation:

1. Creating a Directory:
 Users are prompted to input the desired directory name.
 The script checks if the directory already exists, providing appropriate feedback.
 Additionally, it ensures that the directory name input is not null.

2. Listing the Contents of a Directory:


 Users specify the directory they want to list via system prompt.

4
 The script displays files and subdirectories within the specified directory in an
organized manner.
 Similar to directory creation, the script validates that the directory name input is not
null.

3. Creating an Empty File:


 Users provide the desired filename through a system prompt.
 The script verifies if the file already exists, handling potential naming conflicts
gracefully.
 It also ensures that the filename input is not null.

4. Writing Content to a File:


 Users are prompted to append content to an existing file.
 Specifically, the script prompts users to input their full name, which is then written
to the specified file.
 Like other operations, it validates that the filename input is not null before
proceeding with content writing.

5. Displaying the Content of a File:


 Users can view the contents of a designated file.
 The script presents contents in a readable format to facilitate easy comprehension.
 Non-null filename input validation is performed before displaying content.

6. Deleting a File:
 Users initiate deletion of a specified file via system prompt.
 The script confirms user intent before deletion and adeptly handles potential errors.
 Additionally, it verifies that the filename input is not null before proceeding with
deletion.

7. Deleting a Directory:
 Users can remove a specified directory and its contents recursively.
 The script confirms user intent before deletion and appropriately manages
encountered errors.
 Non-null directory name input is validated before proceeding with deletion.

Each operation in the script initiates interaction by prompting users to input the necessary
directory or file name essential for executing the action. This interactive approach ensures
effective engagement between the script and the user, guiding them seamlessly through each
step of the process. By soliciting user input through prompts, the script facilitates clear
communication and empowers users to navigate file management tasks with ease. This user-
centric design enhances the overall usability of the script, promoting a smooth and intuitive
experience for individuals interacting with it.

5
Snapshot of Each Script: Visualizing File Management Operations

1. Creating a Directory

2. Listing the Contents of a Directory

6
3. Creating an Empty File

4. Writing Content to a File

7
5. Displaying the Content of a File

6. Deleting a File

7. Deleting a Directory

8
8. Option Section of the Script

9. Performing the Task Based on the Chosen Alternative Section of the Script

9
10. Loop Section of the Script

Test Case and Output Screenshot

1. Test Case: Creating a Directory and Handle If Directory Exists


Input: Directory Name: “Padmashree”
Expected Output:
 The script should create the directory "Padmashree" successfully and display a
confirmation message.

10
 If directory “Padmashree” already exist display message directory already exists.

2. Test Case: List the Content of that Directory


Input: Directory Name: "Padmashree"
Expected Output: The script should list the contents of the "Padmashree" directory in a clear and
organized manner

11
3. Test Case: Create Empty File
Input: Filename: "System.txt"
Expected Output: The script should create a new empty file named "System.txt" and
provide a success message.

4. Test Case: Write Content to a File


Input: Filename: "System.txt"
Content: "My Full name "
Expected Output: The script should write the provided content to the file "System.txt" and
display a success message.

5. Test Case: Display Content of File


Input: Filename: "System.txt"
Expected Output: The script should display the contents of the "System.txt" file in a readable
format.

12
X

6. Test Case: Deleting File with confirmation


Input: Filename: "System.txt"
Confirmation: Yes/No
Expected Output:
 The script should delete the file "System.txt" and display a success message.
 The script should prompt the user with a confirmation message before proceeding
with the deletion of the file "System.txt".
 The confirmation message should ask the user to confirm the deletion by typing 'Y'
for yes or 'N' for no.
 Upon entering 'Y' for confirmation, the script should delete the file "System.txt" and
display a success message confirming the deletion.

 If the user enters 'N' or any other input, the script should cancel the deletion
operation and display a corresponding message.

13
7. Test Case: Deleting Directory with Confirmation
Input:
Directory Name: "Padmashree"
Confirmation: Yes/No
Expected Output:
 The script should prompt the user with a confirmation message before proceeding
with the deletion of the directory " Padmashree" and its contents.
 The confirmation message should ask the user to confirm the deletion by typing 'Y'
for yes or 'N' for no.
 Upon entering 'Y' for confirmation, the script should delete the director "
Padmashree" and its contents recursively, displaying a success message confirming
the deletion.

 If the user enters 'N' or any other input, the script should cancel the deletion
operation and display a corresponding message.

14
8. Test Case: Input Validation During Selection
Input:
Input your selection: 9
Expected Output: The system ought to present a prompt requesting the user to input a
valid option, followed by the display of available choices for the user to select from
again.

Invalid Input: Validation:

9. Test Case: Termination of System When Input is 8


Input:
Input your selection: 8
Expected Output: The system should terminate by displaying termination message.

10. Test Case: Validation for Non-Empty File and Directory Names
Input:
Directory/File Name: "Padmashree" or "System.txt"

Expected Output:

15
 The script should detect and display an error message if the user input for
directory or file name is left empty.

Conclusion

Finally, by creating a Bash script, this assignment has given a thorough overview of all the
functions that are necessary for file management in a Linux system. I now have a better grasp
of the nuances involved in efficiently managing data on a system level thanks to the process
of creating, listing, modifying, and removing files and folders.

By breaking down each operation into manageable steps and incorporating user prompts for
input, the script ensures clear communication and user engagement throughout the process.
Additionally, incorporating validation checks for input ensures the script's robustness and

16
guards against potential errors or unintended actions, thereby enhancing its reliability and
usability.

Through this exercise, I've honed my skills in Bash scripting, reinforcing the importance of
clarity, organization, and error handling in code development. Moreover, this assignment has
underscored the significance of user-centric design in creating scripts that are intuitive and
accessible to a wide range of users, regardless of their technical expertise.

Moving forward, I feel more confident in my ability to tackle similar tasks in systems
programming and beyond. The skills acquired through this assignment will undoubtedly
prove invaluable in various professional settings, whether in managing computer systems,
developing software, or engaging in other technical endeavours. Overall, this experience has
been instrumental in broadening my understanding of file management and enhancing my
proficiency in Bash scripting.

References
#LINUX, 2023. freecodecamp.org. [Online]
Available at: https://www.freecodecamp.org/news/bash-scripting-tutorial-linux-shell-script-
and-command-line-for-beginners/
[Accessed 17 March 2024].
Albing , C. & Vossen, J., 2022. Bash Idioms. 1st ed. United States of America: by O'Reilly
Media, Inc., .
Albing, C. & Vossen, J., 2018. Bash Cookbook. 1st ed. United States of America: O' Relliy
Media, Inc.,.
Deitel, P. & Deitel, H., 2013. C How To Program. 7th ed. Delhi: Pearson Education, Inc.,
publishing as Prentic Hall .

17
Marking Scheme

Student Name ID # Program Signature


Raj Bhul 00020691 BIT

Criteria Marks Details Obtained


Marks
Script Structure 5 Clear structure, logical flow, and comprehensive
and Comments comments throughout the script.
User Interaction 10 Includes user-friendly prompts, error messages, and
and Input input validation.
Validation
Implementation of 15 Correct and efficient implementation of all required
File Operations file management operations.
Error Handling 5 Appropriate handling of potential errors (e.g.,
trying to delete a non-existent file/directory).
Proper use of 10 Use of functions properly.
Functions

18
Creativity and 5 Implementation of additional features or creative
Additional approaches to the problem beyond the basic
Features requirements.
Documentation 10 As per documentation requirement.

19

You might also like