piping question

piping question

Post by spamfre » Wed, 31 Dec 1997 04:00:00



I have a program that reads from stdin and writes to stdout.

I have another program that reads from stdin and writes to stdout.

I want to have these two programs 'talk' to one another.

For what it's worth, these programs won't necessarily be sending lines
of information
(so gotta be careful on the 'buffering')

Could someone point to an example how to do this?

please e-mail a reply (remove the spam tag)

 
 
 

1. Fork/redirect/pipe question (checked faq)

Hi,
I'm beating my head against the wall with this portion of a school assignment and
could use a hint.

We're writing a real simple shell that can execute a bunch of commands piped together.
We have to also re-direct a file into the first command that executes and I'm having
problems, for some reason figuring out how to do it.  Is the following scheme the
right path to take?

1) create a pipe
2) fork a child process
3) close write descriptor in child/read in parent
4) execv the command in the child
5) open the file, read it, and send it over the pipe to the child.

Have I got the gist of that, or am I totally out in left field?  If that is a valid
solution, what if we want the commands to run in the background?  It seems to me
that while the shell is processing the file, the shell won't be returned to the
user, allowing the commands to execute in the background.

An example of the type of command I need to chain together from my shell would be:
grep searchterm < inputfile | sort -r > outputfile

Just something that I cam up with that would meet the requirements.

Thanks so much for any assistance!
Rob
--
"This machine will not communicate, the thoughts and the strain I am under."
Radiohead/Street Spirit (Fade Out)

2. Linux moving on up -- EWEEK.com

3. Named Pipe Question

4. enterprise hotswappable server my a$$

5. dd and pipe question

6. SIMS under Apache (SSL)?

7. PIPE Question

8. Apache 1.3.0 on Linux crashes

9. stdout, stderr and pipe question

10. bash: redirection/piping question

11. pipe question