Starting from:

$30

Lab Exercise 2 Introduction to unnamed pipes

# Lab Exercise 2
## Introduction to unnamed pipes


# Table of Content
- [Lab Exercise 2](#lab-exercise-2)
  - [Introduction to unnamed pipes](#introduction-to-unnamed-pipes)
- [Table of Content](#table-of-content)
- [Academic Integrity](#academic-integrity)
- [Keywords](#keywords)
- [Introduction](#introduction)
- [Expected Functionality](#expected-functionality)
- [Starter Code](#starter-code)
- [Rubric](#rubric)
- [Getting started](#getting-started)

# Academic Integrity

The following actions are strictly prohibited and violate the honor code. **The minimum penalty for plagiarism is a grade of zero and a report to the Aggie honor system office.**

- Uploading assignments to external websites or tutoring websites such as Chegg, Coursehero, Stackoverflow, Bartleby, etc.
- Copying code from external websites or tutoring websites such as Chegg, Coursehero, Stackoverflow, Bartleby, etc.
- Copying code from a classmate or unauthorized sources and submitting it as your work.
- Sharing your code with a classmate.

# Keywords

Process, pipe.

# Introduction

The objective of this exercise is to help you get ready for programming assignment 2 by introducing you to basic commands like fork, exec, and pipe.

# Expected Functionality

Your code will be able to execute two commands so that the output of the first command becomes the input of the second command. Both commands should be child processes of the main process (call fork twice). These commands are hardcoded to "ls" and "tr". The output will convert the output of ls into all caps.

# Starter Code

You are given the file shell.cpp to edit and the makefile required to compile the code.In shell.cpp, you have the arrays 'cmd1' and 'cmd2', these can be fed into execvp directly.

In the main function, you should create one unnamed pipe to send the output of ls to the input of tr, using `pipe()`, `fork()`, and `dup2()`.

The command `pipe()` will create an unnamed pipe where you will send the output of ' **ls**' to the write side and set the input of ' **tr**' to the write side of the pipe.

You will use `fork()` to create two child processes that will execute 'ls' and 'tr'. Once the processes have been created, you can use `dup2()` to set the processes' input and output. Finally, perform `execvp()` to start the commands.

# Rubric

Two tests check the compilation and output of the program you coded.

1. Compilation (34 pts)
2. Correct output (66 pts)

# Getting started

The assignment template is hosted on GitHub classroom. Complete the following steps to get started:

1. Go to the assignment's GitHub classroom: [https://classroom.github.com/a/0ucBPg3a](https://classroom.github.com/a/0ucBPg3a)
2. Watch the [Tutorial video](https://www.youtube.com/watch?v=SzGUYBCegKA) (Disregard the title LE1).