GithubHelp home page GithubHelp logo

42-pipex's Introduction

Pipex

So Long

What is Pipex?

• This symbol redirects the standard output of one process to the standard input of another

• The Unix/Linux systems allow stdout of a command to be connected to stdin of another command. You can make it do so by using the pipe character ‘|’.

• The Pipe is a command in Linux that lets you use two or more commands such that output of one command serves as input to the next. In short, the output of each process directly as input to the next one like a pipeline. The symbol ‘|’ denotes a pipe

• Run 2 commands consecutively

How to run - Samples

# Samples of commands
$> ./bin/pipex ./files/file-in "cat" "wc -l" ./files/file-out
$> ./bin/pipex ./files/file-in "cat" "grep Avengers" ./files/file-out

# Commands by program pipex
$> ./pipex ./files/file-inXXXXX "cat" "grep Avengers" ./files/file-out
$> ./bin/pipex ./files/file-in "catXXX" "grep Avengers" ./files/file-out
$> ./bin/pipex ./files/file-in "tr a X" "tr ' ' '\n'" ./files/file-out
$> ./bin/pipex ./files/file-in "tr a b" "tr b ' '" ./files/file-out

# Command by terminal
$> < ./files/file-inXXX cat | grep Avengers > ./files/file-out
$> < ./files/file-in catXXX | grep Avengers > ./files/file-out
$> < ./files/file-in tr a X | tr ' ' '\n' > ./files/file-out
$> < ./files/file-in tr a b | tr b ' ' > ./files/file-out

Argv Params sample

• argv[0]: ./bin/pipex

• argv[1]: ./files/file-in

• argv[2]: cat

• argv[3]: grep Avengers

• argv[4]: ./files/file-out

Envp variables

• envp[33]: QT_X11_NO_MITSHM=1

• envp[34]: WINDOWPATH=2

• envp[35]: PATH=/home/user/.asdf/shims:/home/user/.asdf/bin:/home/user/.local/bin:/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

More information

• Libft allowed.

• Folder structure apply (managed by Makefile).

• No leaks are allowed.

• Norma must be run.

• FD: A file descriptor is a number that uniquely identifies an open file in a computer's operating system. It describes a data resource, and how that resource may be accessed.

• '<' '>' = Redirection operators

#Debug in child process - Before fork apply command in debug console:
$> -exec set follow-fork-mode child

To Run

# Will generate a executable in bin folder
$> make run

# Execute valgrind. Will check memory leaks
$> make leak

# will run norminette inside de .c files (src folder)
$> make norma

Videos

Execute command:

https://youtu.be/uh2FqejQRk8?list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY

Getting exit status code in C:

https://www.youtube.com/watch?v=DiNmwwQWl0g&list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY&index=12

Execute a program / How to execute another program in C (using exec):

https://www.youtube.com/watch?v=OVFEWSP7n8c

The fork() function in C:

https://www.youtube.com/watch?list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY&v=cex9XrZCU14&feature=youtu.be

Waiting for processes to finish (using the wait function) in C

https://www.youtube.com/watch?v=tcYo6hipaSA&list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY&index=2

Dup e Dup2 / Redirecting standard output in C:

https://www.youtube.com/watch?v=5fnVr-zH-SE

Pipes:

https://www.youtube.com/watch?v=Mqb2dVRe0uo&list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY

https://www.youtube.com/watch?v=6xbLgZpOBi8&list=WL&index=23

Tests:

https://github.com/denisgodoy/pipex-tester

42-pipex's People

Contributors

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