Giter Club home page Giter Club logo

pipex's Introduction

Pipex

Mandatory

Pipex is a program that handles pipes and redirections in Unix / Linux systems.

For the mandatory part, here is the syntax that should be given to the program :

 ./pipex infile cmd_1 cmd_2 outfile

For the bonus part, here is the syntax that should be given to the program :

 ./pipex infile cmd_1 ... cmd_n outfile

The program supports heredocument too, here is the syntax that should be given to the program :

 ./pipex here_doc DELIMITER cmd_1 ... cmd_n outfile

In the mandatoy part, I've created one pipe (pipe(2)) to communicate between the two child processes. Then, i forked (fork(2)) twice in the parent process, and i wait for the child processes before returning zero upon successful completion.

Making a command write its output in the pipe, instead of STDOUT_FILENO, is done by using the dup2(2) function.

Visualisation On How To Handle A Single Pipe :

Page_2_3

Bonus

For the bonus part, we have to handle multiple pipes, and « and » when the first parameter is "here_doc".

This command:

 ./pipex file1 cmd1 cmd2 cmd3 ... cmdn file2

Should behave like :

 < file1 cmd1 | cmd2 | cmd3 ... | cmdn > file2

And this :

 ./pipex here_doc LIMITER cmd cmd1 file

Should behave like

$> cmd << LIMITER | cmd1 >> file

Visualisation On How To Handle Multiple Pipes :

Page_1_4

Contributions to this project are welcome! If you find any issues or have improvements to suggest, please feel free to submit a pull request.

License

This project is licensed under the MIT license

pipex's People

Contributors

leakedbytebuster 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.