An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

        





Logo


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
### Requirements

The 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
```