Sponsored Content
Full Discussion: Problems understanding pipes
Top Forums Programming Problems understanding pipes Post 302562633 by ab_tall on Friday 7th of October 2011 01:19:26 PM
Old 10-07-2011
@Corona Apologise if the bumping was excessive..
The fork is done as a part of the line, run the command in a subshell.
Thanks for the explanation though, let me ensure if I am correctly closing the ends of the pipe.

EDIT: Followup question though, is it necessary to use different pipes if there are more than 2 commands in my pipe?
Or can i reuse the same pipe?
say if I want to an ls | grep <pattern> | more.
Once ls is done with its task and grep done with the reading, the pipe would no longer be used right? so can the same be used between grep and more? [I think not..as grep would need access to 2 pipes simultaneously...one to read from and other to write to..in that case I need to address the correct file descriptors in my 2D array]

Last edited by ab_tall; 10-07-2011 at 02:25 PM..
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

PIPEs and Named PIPEs (FIFO) Buffer size

Hello! How I can increase or decrease predefined pipe buffer size? System FreeBSD 4.9 and RedHat Linux 9.0 Thanks! (1 Reply)
Discussion started by: Jus
1 Replies

2. Shell Programming and Scripting

cd using pipes

Hi, Can the cd command be invoked using pipes??? My actual question is slightly different. I am trying to run an executable from different folders and the path of these folders are obtained dynamically from the front end. Is there a way in which i can actually run the executable... (2 Replies)
Discussion started by: Sinbad
2 Replies

3. UNIX for Advanced & Expert Users

FIFO Pipes

Hi...Can anyone please guide me on FIFO Pipes in UNIX.I have lerant things like creating fifo pipes,using them for reads and writes etc.I want to know what is the maximum amount of memory that such a pipe may have? Also can anyone guide me on where to get info on this topic from? (4 Replies)
Discussion started by: tej.buch
4 Replies

4. UNIX for Advanced & Expert Users

Consolidating Pipes

This is something I've given a lot of thought to and come up with no answer. Say you have a data stream passing from a file, through process A, into process B. Process A only modifies a few bytes of the stream, then prints the rest of the stream unmodified. Is there any way to stream the file... (4 Replies)
Discussion started by: Corona688
4 Replies

5. Shell Programming and Scripting

named pipes

How to have a conversation between 2 processes using named pipes? (5 Replies)
Discussion started by: kanchan_agr
5 Replies

6. UNIX for Dummies Questions & Answers

learning about pipes!

im trying to figure out how to do the following: using pipes to combine grep and find commands to print all lines in files that start with the letter f in the current directory that contain the word "test" for example? again using pipes to combine grep and find command, how can I print all... (1 Reply)
Discussion started by: ez45
1 Replies

7. Shell Programming and Scripting

Problems understanding example code

I am really new to UNIX and programming in general and so apologies if this thread is a bit simple. I have searched and found a piece of sample code for a training program I am currently undertaking, but seeing as I am relatively new, I dont completely understand how it works. Here is the... (1 Reply)
Discussion started by: Makaer
1 Replies

8. UNIX for Dummies Questions & Answers

Problems understanding example code

I am really new to UNIX and programming in general and so apologies if this thread is a bit simple. I have searched and found a piece of sample code for a training program I am currently undertaking, but seeing as I am relatively new, I dont completely understand how it works. Here is the... (6 Replies)
Discussion started by: Makaer
6 Replies

9. Programming

Pipes in C

Hello all, I am trying to learn more about programming Unix pipes in C. I have created a pipe that does od -bc < myfile | head Now, I am trying to create od -bc < myfile | head | wc Here is my code, and I know I might be off, thats why I am here so I can get some clarification. #include... (1 Reply)
Discussion started by: petrca
1 Replies

10. Homework & Coursework Questions

Using Pipes and Redirection

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Create a pipe to show the number of people who are logged into the system right now. Create a pipe to show... (2 Replies)
Discussion started by: lakers34kb
2 Replies
pipe(2) 							System Calls Manual							   pipe(2)

NAME
pipe() - create an interprocess channel SYNOPSIS
DESCRIPTION
creates an I/O mechanism called a pipe and returns two file descriptors, fildes[0] and fildes[1]. fildes[0] is opened for reading and fildes[1] is opened for writing. A read-only file descriptor fildes[0] accesses the data written to fildes[1] on a first-in-first-out (FIFO) basis. For details of the I/O behavior of pipes see read(2) and write(2). By default, HP-UX pipes are not STREAMS-based. It is possible to generate the kernel so that all pipes created on a system are STREAMS- based. This can only be done for HP-UX releases 10.0 and later. STREAMS-based FIFOs (created by or are not supported on HP-UX. To generate a kernel that supports STREAMS-based pipes: o STREAMS/UX must be installed. o The module and the driver must be included in the file. (When STREAMS/UX is installed, and are automatically added to the system file.) o The tunable parameter (see streampipes(5)) must be set to 1 in the file. (This is not automatically done when STREAMS/UX is installed.) o The kernel must be generated and the system rebooted. Once this is done, all pipes created by will be STREAMS-based. For more information, see EXAMPLES
The following example uses to implement the command string RETURN VALUE
returns one of the following values: Successful completion. Failure. is set to indicate the error. ERRORS
sets to one of the following error values if the corresponding condition is true. or more file descriptors are currently open. The system file table is full. The file system lacks sufficient space to create the pipe. Could not allocate resources for both Stream heads (STREAMS-based pipes only). SEE ALSO
sh(1), read(2), write(2), popen(3S), privileges(5), streampipes(5), streamio(7). STANDARDS CONFORMANCE
pipe(2)
All times are GMT -4. The time now is 05:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy