Welcome to myshell, a simple command-line interpreter that mimics basic Unix shell functionality. This README serves as a guide for users to understand how to operate myshell effectively.
myshell supports the following internal commands:
cd <directory>: Change the current default directory to<directory>. If<directory>is not provided, it reports the current directory. An appropriate error is reported if<directory>does not exist. This command also updates thePWDenvironment variable.clr: Clear the screen.dir <directory>: List the contents of directory<directory>.environ: List all the environment strings.echo <comment>: Display<comment>on the display followed by a new line. Multiple spaces/tabs may be reduced to a single space.help: Display the user manual using the more filter.pause: Pause operation of the shell until 'Enter' is pressed.quit: Quit the shell.
myshell supports external command as well using the fork and exec method by following these step :
-
If the command is recognized as an internal command, it is executed directly.
-
If it's not an internal command, the shell forks a child process.
-
In the child process, we set the parent environment variable using the setenv function.
-
The external command is then executed using execvp.
-
The parent process waits for the child process to finish using wait(NULL)
Try these to test out:
pwd: prints the current working directory.ls: is a basic command that lists the contents of the current directory.echo: is used to print a message.date: prints the current date and time.
myshell able to take its command line input from a file.
Try these to test out:
-
create a simple batch file named batchfile with a few commands. You can modify it or add more commands as needed. Open a text editor and create a file named batchfile. Add the following commands to the file:
echo This is a batch filelspwd
-
Save the file. Now, you can run your shell in batch mode using the following command:
./myshell batchfile
To install myshell, follow these steps:
- Clone the repository to your local machine.
git clone OS-LAB-2
- Navigate to the directory containing the source code.
cd myshell - Compile the source code using the provided Makefile.
make
- Run the compiled executable file.
./myshell
myshell supports I/O redirection using the following symbols:
<: Redirects input from a file.>: Redirects output to a file.>>: Appends output to a file.
To exit myshell, simply type the quit command or press Ctrl + C.
- Jumaana Aslam - 100778027
- Hasan Khan - 100820450
- Somya Babar - 100851536