42-pipex

📖 Pipex

Implementing Shell Pipes

GitHub code size in bytes Code language count GitHub top language GitHub last commit

Description

Implemented shell pipes and executing simple relative path commands with two types of redirection which is reading a file for the first command and then putting the output in the other file, by forking for every command so they can execute at the same time and the second command will wait for the output from the first one. Using the functions pipe, dup2, fork, and execve implemeting pipes was possible as I used pipe to take the input of the first command and pass it to the second command, dup2 to redirect the output of the commands to another file and be able to take another file as an input, fork to create child processes to be able to execute the commands correctly at the same time, and execve to be abe to execute the commands and take their output.

QuickStart

Makefile is provided so you can execute all files using the following command

make all

then execute with the suitable arguements

  • [file1] => the file to read from.
  • [cmd1] => the command to execute before the pipe.
  • [cmd2] => the command to execute after the pipe.
  • [file2] => the file to put the output of the command inside.
./pipex [file1] [cmd1] [cmd2] [file2]