Skip to content

Latest commit

 

History

History

PIPEX

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

PIPEX

sokim's 42 pipex Score

The aim of this project is to mimic the UNIX mechanism.

⭐ Key concepts

Redirection, Pipes, Process, fork(), dup2()

⭐ Developer notes

🔗리디렉션과 파이프
🔗리눅스 명령 탐색 경로
🔗프로세스 생성과 실행
🔗파일 디스크립터

🚀 Contents

🚩 Mandatory Part

  • The executable file must be named pipex.
  • Handle the errors like the shell command < file1 cmd1 | cmd2 > file2.
  • You are allowed to use the following functions:

◦ access

◦ open

◦ unlink

◦ close

◦ read

◦ write

◦ malloc

◦ waitpid

◦ wait

◦ free

◦ pipe

◦ dup

◦ dup2

◦ execve

◦ fork

◦ perror

◦ strerror

◦ exit

  • The program should be executed in this way

     ./pipex file1 cmd1 cmd2 file2
    
  • Just in case: file1 and file2 are file names, cmd1 and cmd2 are shell commands with their parameters.

  • The execution of the pipex program should do the same as the next shell command:

    < file1 cmd1 | cmd2 > file2
    
  • Examples

     ./pipex infile ``ls -l'' ``wc -l'' outfile
     < infile ls -l | wc -l > outfile
     
     ./pipex infile ``grep a1'' ``wc -w'' outfile
     < infile grep a1 | wc -w > outfile
    

🚩 Bonus Part

  • Handle multiple pipes

     ./pipex file1 cmd1 cmd2 cmd3 ... cmdn file2
     < file1 cmd1 | cmd2 | cmd3 ... | cmdn > file2
    
  • Support « and » when the first parameter is "here_doc"

     ./pipex here_doc LIMITER cmd cmd1 file
     cmd << LIMITER | cmd1 >> file