Implementing pipe concept
This program :.
takes the infile, outfile to redirect the STDIN (<), STDOUT (>) and 2 commands to pipe.
To execute the mandatory program, type the command listed below.
The arguments will be processed as same as < infile cmd1 | cmd2 > outfile on the shell.
The function is written in C language and thus needs the gcc
compiler and some standard C libraries to run.
1. To use the function in your code, simply include its header:
#include "pipex_mandatory.h"
Simply run this command :
make && ./pipex <infile> <cmd1> <cmd2> <outfile>
As a
bonus
to the Mandatory requirement, the function should manage multiple commands or here_doc.
- It supports both single (>) and double (>>) angle brackets for STDOUT.
- The single angle bracket (>) overwrites the entire file.
- The double angle bracket (>>) appends to the file.
- Arguments with an index of 1 will use the here_doc feature.
- For STDIN, it supports the double angle bracket (<<) instead of the single angle bracket (<).
- The infile will be replaced.
- Lines typed by the user will be written to STDIN until a specified limiter is typed.
- Once the limiter is typed, the first command will be executed using all the lines from STDIN, except the limiter.
1. To use the function in your code, simply include its header:
#include "pipex_bonus.h"
Simply run this command :
make bonus && ./pipex_bonus <infile> <cmd1> <cmd2> ... <outfile>
Or :
make bonus && ./pipex_bonus "here_doc" <limiter> <cmd1> <cmd2> ... <outfile>