Pipex is a program that handles pipes and redirections in Unix / Linux systems.
For the mandatory part :
make
./pipex infile cmd_1 cmd_2 outfile
For the bonus part :
make
./pipex infile cmd_1 ... cmd_n outfile
The program supports heredocument too, here is the syntax that should be given to the program :
./pipex here_doc DELIMITER cmd_1 ... cmd_n outfile
In the mandatoy part, I've created one pipe (pipe(2)) to communicate between the two child processes. Then, i forked (fork(2)) twice in the parent process, and i wait for the child processes before returning zero upon successful completion.
Making a command write its output in the pipe, instead of STDOUT_FILENO, is done by using the dup2(2) function.
For the bonus part, we have to handle multiple pipes, and «
and »
when the first parameter is "here_doc".
./pipex file1 cmd1 cmd2 cmd3 ... cmdn file2
Should behave like :
< file1 cmd1 | cmd2 | cmd3 ... | cmdn > file2
./pipex here_doc LIMITER cmd cmd1 file
Should behave like
$> cmd << LIMITER | cmd1 >> file
This project is licensed under the MIT license