- The program has to behave like this shell command:
< infile cmd1 | cmd2 > outfile
- The program gets executed the following way:
./pipex "infile" "cmd1" "cmd2" "outfile"
- The program only works for UNIX-like operating systems.
- The program pipes the contents of the "infile" into the first command "cmd1".
- The first command gets executed, the results get piped into the second command "cmd2".
- The second command gets executed and the output is written to "outfile". All existing contents of the "outfile" are overwritten (If the program has no output, "outfile" will be empty").
- The "outfile" will get overwritten!
- In addition to the basic functioning of the project, you can insert as many commands as you want into the project:
./pipex "infile" "cmd1" "cmd2" "..." "cmdn" "outfile"
- The program can also simulate the following shell command:
cmd << LIMITER | cmd1 >> outfile
- For this the program has to be executed the following way:
./pipex here_doc "LIMITER" "cmd" "cmd1" "outfile"
- If the program is called with here_doc as first parameter, the User can input text into the command line, once a line is the same as specified, the program stops reading and executes the commands.
- In addition, with here_doc, the "outfile" will not be overwritten, but the results will be appended to it.
- Clone the repository:
git clone https://github.com/itseugen/pipex
- Enter the directory and build the program:
cd pipex
make
Optional: Clean object files:
make clean
- Create a input file (the program needs an existing input file, if the output file is missing it will be created):
touch input.txt
- Run the program like explained above, you need at least for arguments. Example:
./pipex "input.txt" "grep Hello" "wc -w" "output.txt"
This project is part of my studies at 42 Heilbronn