Skip to content

Aztaban/pipex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PIPEX

This project is a simplified implementation of shell pipelines. It mimics the shell's ability to pipe commands using the | operator. The program handles input/output redirection and command execution using fork(), execve(), and pipe() system calls.


🛠 Usage

./pipex infile "cmd1" "cmd2" outfile

Equivalent to:

< infile cmd1 | cmd2 > outfile

✅ Example

./pipex input.txt "grep hello" "wc -l" output.txt

This reads from input.txt, runs grep hello, pipes the result into wc -l, and writes the output to output.txt.


🔧 Bonus Features

./pipex here_doc LIMITER cmd1 cmd2 ... cmdN outfile

Supports:

  • Multiple commands (cmd1 | cmd2 | ... | cmdN)
  • here_doc functionality: reads input from stdin until the given LIMITER.
  • Appends to the output file if here_doc is used.

Bonus Example

./pipex here_doc END "cat" "grep hello" "wc -l" output.txt

📂 File Structure

├── include/
│   ├── pipex.h              # Header file for mandatory part
│   └── pipex_bonus.h        # Header for bonus features
├── libft/                   # Libft library
├── src/
│   ├── main.c               # Entry point for mandatory part
│   ├── process.c            # Process execution (mandatory)
│   ├── pathfinder.c         # PATH resolution for commands
│   ├── helpers.c            # Common error/child handlers
├── src_bonus/
│   ├── main_bonus.c         # Entry for bonus (multi-pipe, here_doc)
│   ├── process_bonus.c      # Process handling with multiple pipes
│   ├── pathfinder.c         # PATH resolution for commands
│   ├── helpers.c            # Common error/child handlers
├── Makefile                 # Builds the project and handles rules
└── README.md                # You're reading it!

🛠️ Compilation

To build the project, run:

make              # Builds the mandatory version
make bonus        # Builds the bonus version
make clean        # Removes object files
make fclean       # Removes all binaries and objects
make re           # Rebuilds everything

👤 Author

Created and maintained by Martin Justa as part of the 42 school curriculum.

About

A simplified shell-like pipe mechanism in C. This project replicates the shell behavior of piping commands and builds understanding of processes, pipes, file descriptors, and execve.

Topics

Resources

Stars

Watchers

Forks

Contributors