Releases: Brawun/OperatingSystemsBFU
Release list
PS5 - Test Rep
Test Report: My Simple Shell
Overview
This repository contains a simple test report for the SimpleShell project, which is a basic interactive shell written in C++. The SimpleShell allows users to execute standard commands, supports input/output redirection, and handles command piping.
The test report details the testing performed on SimpleShell to verify its functionality, including command execution, error handling, and exit conditions. The goal was to ensure that the shell operates as expected under normal use and provides proper feedback for invalid operations.
Contents
- test_report.txt: A text file summarizing the tests conducted on the SimpleShell program. It includes details about the test environment, test cases, results, and recommendations for future enhancements.
How to Use
-
Review the Test Report: The
test_report.txtfile contains a comprehensive summary of each test case, including the commands tested, expected outcomes, actual results, and whether the tests passed or failed. -
Test Environment: The tests were conducted on Ubuntu 20.04 using g++ 9.3.0 as the compiler. If you wish to reproduce the tests, ensure your environment matches or is compatible.
-
Future Enhancements: Recommendations are included in the report for extending the shell's functionality, such as adding command history and improved signal handling.
Summary of Results
- Total Test Cases: 10
- Passed: 10
- Failed: 0
The SimpleShell project has passed all the test cases outlined in the report. The report also includes additional suggestions to enhance the shell's usability and robustness.
Recommendations
- Implement signal handling to manage commands like
Ctrl+Cwithout exiting the shell entirely. - Add a command history feature to enhance user experience by allowing previously executed commands to be recalled easily.
Conclusion
The SimpleShell performed as expected for all test cases, confirming its robustness for basic shell operations. It is now well-positioned for future feature enhancements and improvements.
PS4 - Simple Shell with Pipes
My Simple Shell
SimpleShell is a simple, interactive shell program written in C++. It allows users to enter basic commands, which are then executed as separate processes. The shell provides basic functionality, such as command parsing and execution, through a continuous loop that reads user input, interprets the command, and displays results. This shell program is intentionally minimal, making it a starting point for learning shell basics and process management in C++.
Features
- Command Parsing: User inputs are tokenized into commands and arguments, allowing a variety of commands with arguments.
- Command Execution: Each command runs in a child process, created using
fork()and executed withexecvp(). - Looping Prompt: The shell continuously prompts users for commands until they signal EOF (e.g.,
Ctrl+D). - Input/Output Redirection: Supports redirection of input and output using
<and>symbols. For example,command < input.txt > output.txtredirects standard input frominput.txtand standard output tooutput.txt. - Pipe Handling: Supports command piping using
|to pass the output of one command as input to another. For example,cat file.txt | grep pattern. - Basic Error Handling: Provides feedback for failed executions or invalid commands.
Program Structure
- SimpleShell.h: Defines the
SimpleShellclass, including methods for running the shell loop, parsing input, and executing commands. - SimpleShell.cpp: Implements the
SimpleShellclass, containing the core functionality of the shell. - Makefile: A Makefile for compiling, running, and cleaning up the program.
File Descriptions
SimpleShell.h: Header file containing the declarations of the shell methods and class structure.SimpleShell.cpp: Source file with the full implementation of the shell’s features, including command parsing, execution, and pipe handling.Makefile: Used to compile, run, and clean the program with simple commands.
How to Build and Run the Program
Prerequisites
- C++ Compiler: Ensure you have a C++11-compatible compiler installed (e.g.,
g++). - Make: Make should be installed to use the Makefile commands.
Compilation and Execution
Open a terminal in the project directory and use the following commands:
make # Compiles and runs the program
make compile # Only compiles the program and creates an executable in bin/
make run # Executes the compiled program
make clean # Cleans up object files and the executable in bin/Using SimpleShell
- Run the shell using
makeormake run. - When the prompt
SimpleShell %appears, type any standard command (e.g.,ls,pwd,echo Hello). - Press Enter to execute the command.
- To exit the shell, type Ctrl+D or terminate the process.
Example Session
SimpleShell % ls
file1.cpp file2.cpp SimpleShell.cpp bin
SimpleShell % echo "Hello, SimpleShell!"
Hello, SimpleShell!
SimpleShell % pwd
/home/user/Simpleshell
SimpleShell % cat < input.txt | grep pattern > output.txt
SimpleShell % invalidcommand
Execution failed: No such file or directory
SimpleShell % Ctrl+DCode Overview
- Shell Loop (
run()): The main loop displays the prompt, reads user input, parses it, and executes the command. - Command Parsing (
parse()): Splits the input string by spaces to form a command and argument list. - Command Execution (
execute()): Usesfork()to create a new process andexecvp()to run the command in the child process. Handles input and output redirection using<and>and handles pipes (|) for command chaining.
Future Extensions
SimpleShell is designed as a minimalistic shell, ideal for adding more advanced features, such as:
- Append Output Redirection: Supporting
>>to append output to a file. - Signal Handling: Implementing custom handling for signals (e.g.,
Ctrl+Cto terminate commands). - Environment Variables: Supporting access and modification of environment variables.
- Command History: Adding support for maintaining a history of commands, allowing users to recall previous commands easily.
Troubleshooting
- "Execution failed" Error: If a command cannot be found, ensure it’s installed and accessible in your system’s
PATH. - Compilation Errors: Ensure your environment supports C++11 or later and that
makeis installed.
Author
Brandon Figueroa Ugalde - ID# 660282688
PS3 - Simple Shell with I/O Redirection
My Simple Shell
SimpleShell is a simple, interactive shell program written in C++. It allows users to enter basic commands, which are then executed as separate processes. The shell provides basic functionality, such as command parsing and execution, through a continuous loop that reads user input, interprets the command, and displays results. This shell program is intentionally minimal, making it a starting point for learning shell basics and process management in C++.
Features
- Command Parsing: User inputs are tokenized into commands and arguments, allowing a variety of commands with arguments.
- Command Execution: Each command runs in a child process, created using
fork()and executed withexecvp(). - Looping Prompt: The shell continuously prompts users for commands until they signal EOF (e.g.,
Ctrl+D). - Input/Output Redirection: Supports redirection of input and output using
<and>symbols. For example,command < input.txt > output.txtredirects standard input frominput.txtand standard output tooutput.txt. - Basic Error Handling: Provides feedback for failed executions or invalid commands.
Program Structure
- SimpleShell.h: Defines the
SimpleShellclass, including methods for running the shell loop, parsing input, and executing commands. - SimpleShell.cpp: Implements the
SimpleShellclass, containing the core functionality of the shell. - Makefile: A Makefile for compiling, running, and cleaning up the program.
File Descriptions
SimpleShell.h: Header file containing the declarations of the shell methods and class structure.SimpleShell.cpp: Source file with the full implementation of the shell’s features, including command parsing and execution.Makefile: Used to compile, run, and clean the program with simple commands.
How to Build and Run the Program
Prerequisites
- C++ Compiler: Ensure you have a C++11-compatible compiler installed (e.g.,
g++). - Make: Make should be installed to use the Makefile commands.
Compilation and Execution
Open a terminal in the project directory and use the following commands:
make # Compiles and runs the program
make compile # Only compiles the program and creates an executable in bin/
make run # Executes the compiled program
make clean # Cleans up object files and the executable in bin/Using SimpleShell
- Run the shell using
makeormake run. - When the prompt
SimpleShell %appears, type any standard command (e.g.,ls,pwd,echo Hello). - Press Enter to execute the command.
- To exit the shell, type Ctrl+D or terminate the process.
Example Session
SimpleShell % ls
file1.cpp file2.cpp SimpleShell.cpp bin
SimpleShell % echo "Hello, SimpleShell!"
Hello, SimpleShell!
SimpleShell % pwd
/home/user/Simpleshell
SimpleShell % cat < input.txt > output.txt
SimpleShell % invalidcommand
Execution failed: No such file or directory
SimpleShell % Ctrl+DCode Overview
- Shell Loop (
run()): The main loop displays the prompt, reads user input, parses it, and executes the command. - Command Parsing (
parse()): Splits the input string by spaces to form a command and argument list. - Command Execution (
execute()): Usesfork()to create a new process andexecvp()to run the command in the child process. Handles input and output redirection using<and>.
Future Extensions
SimpleShell is designed as a minimalistic shell, ideal for adding more advanced features, such as:
- Pipe Handling: Allowing commands to be chained (e.g.,
ls | grep file). - Append Output Redirection: Supporting
>>to append output to a file. - Signal Handling: Implementing custom handling for signals (e.g.,
Ctrl+Cto terminate commands). - Environment Variables: Supporting access and modification of environment variables.
Troubleshooting
- "Execution failed" Error: If a command cannot be found, ensure it’s installed and accessible in your system’s
PATH. - Compilation Errors: Ensure your environment supports C++11 or later and that
makeis installed.
Author
Brandon Figueroa Ugalde - ID# 660282688
PS2 - Simple Shell
My Simple Shell
SimpleShell is a simple, interactive shell program written in C++. It allows users to enter basic commands, which are then executed as separate processes. The shell provides basic functionality, such as command parsing and execution, through a continuous loop that reads user input, interprets the command, and displays results. This shell program is intentionally minimal, making it a starting point for learning shell basics and process management in C++.
Features
- Command Parsing: User inputs are tokenized into commands and arguments, allowing a variety of commands with arguments.
- Command Execution: Each command runs in a child process, created using
fork()and executed withexecvp(). - Looping Prompt: The shell continuously prompts users for commands until they signal EOF (e.g.,
Ctrl+D). - Basic Error Handling: Provides feedback for failed executions or invalid commands.
Program Structure
- SimpleShell.h: Defines the
SimpleShellclass, including methods for running the shell loop, parsing input, and executing commands. - SimpleShell.cpp: Implements the
SimpleShellclass, containing the core functionality of the shell. - Makefile: A Makefile for compiling, running, and cleaning up the program.
File Descriptions
SimpleShell.h: Header file containing the declarations of the shell methods and class structure.SimpleShell.cpp: Source file with the full implementation of the shell’s features, including command parsing and execution.Makefile: Used to compile, run, and clean the program with simple commands.
How to Build and Run the Program
Prerequisites
- C++ Compiler: Ensure you have a C++11-compatible compiler installed (e.g.,
g++). - Make: Make should be installed to use the Makefile commands.
Compilation and Execution
Open a terminal in the project directory and use the following commands:
make # Compiles and runs the program
make compile # Only compiles the program and creates an executable in bin/
make run # Executes the compiled program
make clean # Cleans up object files and the executable in bin/Using SimpleShell
- Run the shell using
makeormake run. - When the prompt
SimpleShell %appears, type any standard command (e.g.,ls,pwd,echo Hello). - Press Enter to execute the command.
- To exit the shell, type Ctrl+D or terminate the process.
Example Session
SimpleShell % ls
file1.cpp file2.cpp SimpleShell.cpp bin
SimpleShell % echo "Hello, SimpleShell!"
Hello, SimpleShell!
SimpleShell % pwd
/home/user/Simpleshell
SimpleShell % invalidcommand
Execution failed: No such file or directory
SimpleShell % Ctrl+DCode Overview
- Shell Loop (
run()): The main loop displays the prompt, reads user input, parses it, and executes the command. - Command Parsing (
parse()): Splits the input string by spaces to form a command and argument list. - Command Execution (
execute()): Usesfork()to create a new process andexecvp()to run the command in the child process. If the command fails, an error message is displayed.
Future Extensions
SimpleShell is designed as a minimalistic shell, ideal for adding more advanced features, such as:
- Pipe Handling: Allowing commands to be chained (e.g.,
ls | grep file). - Input/Output Redirection: Enabling input and output redirection with
>,<, and>>. - Signal Handling: Implementing custom handling for signals (e.g.,
Ctrl+Cto terminate commands). - Environment Variables: Supporting access and modification of environment variables.
Troubleshooting
- "Execution failed" Error: If a command cannot be found, ensure it’s installed and accessible in your system’s
PATH. - Compilation Errors: Ensure your environment supports C++11 or later and that
makeis installed.
Author
Brandon Figueroa Ugalde - ID# 660282688