Question
For this assignment, you will add support for i/o redirection and piping to the shell code given below. That is to say, >, file.txt cat
For this assignment, you will add support for i/o redirection and piping to the shell code given below. That is to say, >, <, and |.
For example, your shell should now support commands like this :
ls -l > file.txt
cat file.txt | wc > file.txt
sort < file.txt
Your shell does not need to support "chained" piping. That is your shell is not required to do this:
ls | sort | wc | head
CODE:
Main.c (sh.c):
#include
parse.h:
#ifndef PARSE_H #define PARSE_H #include "string.h" //function for parse static void parse(char* input, char* args[]) { int i = 0; //fgets reads the , so overwrite it input[strlen(input)-1] = '\0'; //get the first token args[i] = strtok( input, " " ); //get the rest of them while((args[++i] = strtok(NULL, " "))); } #endif
runCommand.h:
#ifndef RUNCOMMAND_H #define RUNCOMMAND_H #include
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