Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your task is to write a UNIX - like shell program that works in our Linux machine in Lab FH 1 3 3 E .
Your task is to write a UNIXlike shell program that works in our Linux machine in Lab FH E A shell is a command line interface for users.
It accepts usercommands and execute them. Under the hood, a shell is just another user program. For eamples, binshbinbashbintcsh etc.,
are popular shells in UnixLinux systems. In this assignment, you will implement your own shell, named as "myshell".
points Your shell should repeatedly display a prompt and allow the user to enter a command to run. Your shell is supposed to read the input from system standard input, parse the line with command and arguments, and execute. You must use fork and execv system calls.
Given a user command, your shell should try to find the buildin commands see part first. If not found, it should search the directories stored in the pathname environment your impelementation For example, if bin appears in the pathname environment, your shell should automatically support most Linux shell commands.
You are not allowed to use system or any similar function that invoke the system's binsh shell. Again, you are only allowed to use fork and execv to create a process and execute the user command. Note that you cannot use execlp or execvp because these will use the system's pathname environment.
By convention, the command arguments are separated by white spaces. Your implementation should follow this rule. Your shell does not need to handle special characters like & except input redirection and output redirection
If the user command cannot be found, ie neither a buildin command nor a command can be found in the directories contained in the pathname environment, your shell must give a meaningful response and then continue display a prompt for the next command.
points Buildin commands:
cd: is a command that changes directories. You should use chdir system call to achieve it
path: is not only a command that shows the current command searching pathname environment if no argument is given but also a utility to modify the pathname environment.
path without argument: display the current pathname environment, egbin:sbin Note, your shell starts with an empty pathname environment.
path abcdef: appends directory abcdef to the end of the pathname environment.
path abcdef: removes pathname abcdef from the pathname environment if it exists. Otherwise, do nothing.
quit: a command to terminate your shell.
points Extend your shell to support IO redirection: input redirection and output redirection You must use open close and dup system calls. Your shell does not need to handle redirection for above buildin commands. Note that either or or both may appear in a user's command.
points README and makefile: must be a text file not a PDF docx, or rtf Document your design ideas in this README file. In particular, provide an instructions how to compile your code, how to run your program, and provide a sample test output again in text format Finally, provide a statement if your code contains any bugs or miss a certain component. You must provide a makefile such that the grader can compile your code by simply typing "make".
System input and output rules: in this project, you can only use fgets function to take the keyboard inputs, eg fgetsbuffer stdin will capture a user command in a preprepared buffer with size of bytes. For system output, you should use printf function. All file inputoutput must be performed via system calls, including open close The library calls such as fopen fread are not allowed in this project.
cd command is not changing the directories
I am getting the below output
tavarigo@spirit:~$ gcc mshellc o mshell
tavarigo@spirit:~$ mshell
myshell path bin
myshell: Success
myshell ls
myshell: Success
myshell cd
myshell: Success
myshell pwd
myshell: Success
myshell echo "hello world" output.txt
myshell: Success
myshell cat output.txt
myshell: No such file or directory
myshell path
myshell: Success
myshell quit
myshell: Success
Please correct it
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started