The purpose of this assignment is to learn to develop multi-process programs. You are expected to extend the myshell.c program and add pipelines and I/O redirections. In particular, your shell program should recognize the following: > - Redirect standard output from a command to a file. Note: if the file already exists, it will be erased and overwritten without warning. For example, COP4338$ ls > 1 COP4338$ sort myshell.c > 2 Note that you're not supposed to implement the Unix commands (ls, sort, ...). You do need to implement the shell that invoke these commands and you need to "wire" up the standard input and output so that they "chain" up as expected. >> - Append standard output from a command to a file if the file exists; if the file does not exist, create one. For example, COP4338$ sort myshell.c >> 1 COP4338$ echo "Add A Line" >> 1 < - Redirect the standard input to be from a file, rather than the keyboard. For example, COP4338$ sort < myshell.c COP4338$ sort < myshell.c > 1 COP4338$ sort > 1 < myshell.c The second and third commands are the same: the sort program reads the file named myshell.c as standard input, sorts it, and then writes to file named 1. | - Pass the standard output of one command to another for further processing. For example, COP4338$ ls | sort COP4338$ sort < myshell.c | grep main | cat > output Make sure you have your parent process fork the children and 'wire' them up using pipes accordingly. There will be spaces separating tokens in the command line. Your program should be able to run with all the Unix commands as expected. Don't assume your program will only be tested by the above commands. Also, there could be more than two commands chained by pipes, like the second example above. Your program needs to provide necessary sanity-check from the user input. Prompt meaningful errors accordingly as what you'd experience with your shell. Hint: use strtok() functions to separate the tokens and use strstr() to locate sub-strings.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question
100%

The purpose of this assignment is to learn to develop multi-process programs. You are expected to extend the myshell.c program and add pipelines and I/O redirections. In particular, your shell program should recognize the following:

> - Redirect standard output from a command to a file. Note: if the file already exists, it will be erased and overwritten without warning. For example,

COP4338$ ls > 1
COP4338$ sort myshell.c > 2
Note that you're not supposed to implement the Unix commands (ls, sort, ...). You do need to implement the shell that invoke these commands and you need to "wire" up the standard input and output so that they "chain" up as expected.

>> - Append standard output from a command to a file if the file exists; if the file does not exist, create one. For example,

COP4338$ sort myshell.c >> 1
COP4338$ echo "Add A Line" >> 1
< - Redirect the standard input to be from a file, rather than the keyboard. For example,

COP4338$ sort < myshell.c
COP4338$ sort < myshell.c > 1
COP4338$ sort > 1 < myshell.c
The second and third commands are the same: the sort program reads the file named myshell.c as standard input, sorts it, and then writes to file named 1.

| - Pass the standard output of one command to another for further processing.
For example,

COP4338$ ls | sort
COP4338$ sort < myshell.c | grep main | cat > output
Make sure you have your parent process fork the children and 'wire' them up using pipes accordingly. There will be spaces separating tokens in the command line. Your program should be able to run with all the Unix commands as expected. Don't assume your program will only be tested by the above commands. Also, there could be more than two commands chained by pipes, like the second example above.

Your program needs to provide necessary sanity-check from the user input. Prompt meaningful errors accordingly as what you'd experience with your shell.

Hint: use strtok() functions to separate the tokens and use strstr() to locate sub-strings.

Expert Solution
steps

Step by step

Solved in 2 steps with 18 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education