-----> PDF <-----
The project was made to recreate what a pipe does.
It should work by using the following command line: './pipex infile "cmd 1" "cmd 2" outfile'
infile
being the file that contains the information you want treatedcmd 1
is the first command you want to be executed on theinfile
;cmd 2
is the second command that will be executed on the output ofcmd 1
;outfile
is the file where the result ofcmd 2
will be stored;
An example of this could be: ./pipex chicken_recipe.txt "cat -e" "wc -l" recipe_length.txt
which would gives me the number of lines the infile has.
This project is quite straight forward. There are a few ways to do it, but they all revolve around the same idea.
There are a few videos from CodeVault on youtube that explain in a lot of detail how to get this done`
I also used these guides to help me with some questions I had during the project:
- Pipex Tutorial
- Korean Guide for Pipex (If you dont know Korean, use a translator. If you do know, lucky you)
- The
execve()
function works in the following way:
int execve(const char *pathname, char *const argv[], char *const envp[])
pathname
will be the environment path followed by the command itself (without flags). To view all paths you can useenv
call on your command line and check the envirnment variablePath=
;argv
will be the command (with flags);envp
is an array of pointers to environment variables. Basically it's whatenv
shows.
-
To prevent errors, be sure to add a
/
in between the path and the command on yourpathname
-
The bonus part is important for future projects! Although I didn't do it, the project bonus part is one of the few that will actually be required in a future project (MiniShell).