https://github.com/dpetrosy/42-pipex
42 School Pipex project aimed to better understand shell redirection and pipes, by handling them in C.
https://github.com/dpetrosy/42-pipex
42 42-pipex 42born2code 42cursus 42pipex 42projects 42school 42yerevan c c-programming child-process command-line dup2 execve fork pipes pipex pipex-42 pipex42 shell
Last synced: about 1 month ago
JSON representation
42 School Pipex project aimed to better understand shell redirection and pipes, by handling them in C.
- Host: GitHub
- URL: https://github.com/dpetrosy/42-pipex
- Owner: dpetrosy
- License: mit
- Created: 2024-03-06T12:18:15.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-03T13:20:57.000Z (about 1 year ago)
- Last Synced: 2025-01-29T18:46:40.649Z (3 months ago)
- Topics: 42, 42-pipex, 42born2code, 42cursus, 42pipex, 42projects, 42school, 42yerevan, c, c-programming, child-process, command-line, dup2, execve, fork, pipes, pipex, pipex-42, pipex42, shell
- Language: C
- Homepage:
- Size: 1.5 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
Pipex Project
42 Yerevan Pipex
For further information about 42cursus and its projects, please refer to 42cursus repo.
![]()
![]()
![]()
![]()
![]()
๐ About Project
ยท
๐ท Mandatory Part
ยท
๐ Bonus Part
ยท
๐จโ๐ป Usage
---
## ๐ About Project
> This pipex program takes an input file, performs a command on it, pipes the result to another command which then writes its result to an output file. The result is virtually identical to this kind of shell command.
For detailed information, refer to the [**subject of this project**](README_files/pipex_subject.pdf).
๐ TLDR: Pipex is a 42 School project aimed to better understand shell redirection and
pipes, by handling them in C.> [!NOTE]
> Because of 42 School norm requirements:
> * Each function can't have more than 25 lines of code.
> * All variables are declared and aligned at the top of each function.
> * Project should be created just with allowed functions otherwise it's cheating.## ๐ท Mandatory Part
The program `pipex` should repeat the behavior of the next shell command:
```bash
$> < file1 cmd1 | cmd2 > file2
```
and looks like this:
```bash
$> ./pipex file1 cmd1 cmd2 file2
```> [!NOTE]
> All errors like: wrong commands, permission to files and etc are handled.## ๐ Bonus Part
Program needs to handle multiple pipes:
```bash
$> < file1 cmd1 | cmd2 | cmd3 | ... | cmdn > file2
```and looks like this:
```bash
$> ./pipex file1 cmd1 cmd2 cmd3 ... cmdn file2
```## ๐จโ๐ป Usage
### RequirementsThe program is written in C language and thus needs the **gcc compiler** and some standard **C libraries** to run.
### Instructions
**1. Compiling the program**
To compile the program, run:
```shell
$ cd path/to/pipex && make
```**2. How to run the program**
Run the executable with commands of your choice:
```shell
./pipex input "cat" "wc -l" output
```Use `clean` to delete all object files, `fclean` to remove executable and all object files, and `re` to recompile the program:
```shell
make clean / make fclean / make re
```