Skip to content

This project is the discovery in detail and by programming of a UNIX mechanism that you already know.

Notifications You must be signed in to change notification settings

J0Santos/42-pipex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pipex 📮

Grade 🧑‍🎓

Grade

Introduction

-----> PDF <-----

The project was made to recreate what a pipe does.

It should work by using the following command line: './pipex infile "cmd 1" "cmd 2" outfile'

  • infile being the file that contains the information you want treated
  • cmd 1 is the first command you want to be executed on the infile;
  • cmd 2 is the second command that will be executed on the output of cmd 1;
  • outfile is the file where the result of cmd 2 will be stored;

An example of this could be: ./pipex chicken_recipe.txt "cat -e" "wc -l" recipe_length.txt which would gives me the number of lines the infile has.

Method 🧪

This project is quite straight forward. There are a few ways to do it, but they all revolve around the same idea.

There are a few videos from CodeVault on youtube that explain in a lot of detail how to get this done`

I also used these guides to help me with some questions I had during the project:

Observations

  1. The execve() function works in the following way:
int execve(const char *pathname, char *const argv[], char *const envp[])
  • pathname will be the environment path followed by the command itself (without flags). To view all paths you can use env call on your command line and check the envirnment variable Path=;
  • argv will be the command (with flags);
  • envp is an array of pointers to environment variables. Basically it's what env shows.
  1. To prevent errors, be sure to add a / in between the path and the command on your pathname

  2. The bonus part is important for future projects! Although I didn't do it, the project bonus part is one of the few that will actually be required in a future project (MiniShell).

About

This project is the discovery in detail and by programming of a UNIX mechanism that you already know.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published