The pipex
project at 42 school challenges students to craft a program emulating the intricacies of shell command pipelines in the C language.
This endeavor necessitates a deep comprehension of process creation, manipulation, and input/output redirection. Students are tasked with orchestrating a sequence of commands, efficiently directing the output of one command as the input for the next.
The project not only hones skills in managing processes but also delves into the nuances of handling file descriptors and executing commands in a seamless chain.
Successfully completing pipex
showcases a mastery of process manipulation and solidifies the understanding of pivotal system calls in Unix-like operating systems.
The program behaves like this :
./pipex file1 cmd1 cmd2 file2
which mimics the real shell command
< file1 cmd1 | cmd2 > file2
Examples :
./pipex infile.txt "ls -l" "wc -l" outfile.txt
Important
The way the project is built means that pipex
is expecting COMMANDS AND OPTIONS grouped in a single argument, surrounded with "double-quotes".
The command :
./pipex infile.txt ls -l wc -l outfile.txt
will actually fail.
Clone the project :
git clone https://github.com/maitreverge/pipex.git && cd pipex
Build the project in your shell environment running :
make
You'll end up with an pipex
executable file.
Let's make a basic example.
You'll need to create an infile.txt
from which pipex
will read in STD_IN
:
echo "Hello, World\!" > infile.txt
Execute pipex
:
./pipex infile.txt "cat" "rev" outfile.txt
This will create an outfile from which you can read :
cat outfile.txt
You should see the bellow result :
!dlroW ,olleH
Contributions are open, make a pull request or open an issue 🚀