Giter Club home page Giter Club logo

42-pipex's Introduction

42-pipex

Unix System Programming and Pipelines: A Pipex Project Overview

This is a project for 42Heilbronn school's curriculum.

The goal of the project is to write a program that will implement the behavior of the shell | and redirections.

Description

mandatory part:

run make

The program behaves exactly the same as this shell command:

$> < file1 cmd1 | cmd2 > file2

The program will be executed as follows:

./pipex file1 cmd1 cmd2 file2

  • file1: the name of the input file
  • cmd1: the first shell command to be executed with its parameters
  • cmd2: the second shell command to be executed with its parameters
  • file2: the name of the output file

e.g: $> ./pipex infile "ls -l" "wc -l" outfile should behave like: < infile ls -l | wc -l > outfile

bonus part:

run make bonus

  • Handling multiple pipes:

./pipex file1 cmd1 cmd2 cmd3 ... cmdn file2 should behave like < file1 cmd1 | cmd2 | cmd3 ... | cmdn > file2.

  • Supporting << and >> when the first parameter is "here_doc":

./pipex here_doc LIMITER cmd cmd1 ... cmdn file should behave like cmd << LIMITER | cmd1 ... | cmdn >> file.

What i learned:

  • how to use pipes to redirect input and output between multiple processes.
  • how to check for unclosed pipes using the lsof command.
  • how to use the fork() function to create child processes.
  • how to use the execve() function to execute shell commands in child processes.
  • how to use file descriptors, such as dup() and dup2(), to redirect input and output between processes.
  • how to handle errors and manage memory to avoid issues like memory leaks and unexpected program termination.
  • Bonus: Handling multiple pipes and supporting << and >> for "here_doc" input.

These concepts are fundamental to Unix system programming and pipelines, and are widely used in various applications, such as data processing and networking.

42-pipex's People

Contributors

annafenzl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.