3

I remember vaguely a technique using pipes for communication between two shell processes.

Are there any tutorials available on how to setup and control a subshell?

1
  • 1
    Can you give more detail about what you are trying to accomplish? If you just trying to autopilot a subprocess, expect might be a better choice. Commented Jul 21, 2010 at 14:14

4 Answers 4

2

Are you talking about named pipes?

mkfifo pipe
ls -l >pipe #type this is one shell
cat <pipe #type this is another one

No one reads if no one writes.
No one writes if no one reads.

Sign up to request clarification or add additional context in comments.

Comments

1

Did you take a look at the Advanced Bash Scripting guide?

There's an entire chapter about - surprise surprise - subshells.

2 Comments

@sm - thanks I knows this guide, but my problem is rather how to communicate between the processes
Sorry mate, I didn't read your question carefully enough. How about this linuxjournal.com/content/using-named-pipes-fifos-bash ?
1

This should get you going, examples are in C, but the same technique applies to bash. Just do a search for named pipes, in google or here, alot of examples specific to bash pops up.

http://developers.sun.com/solaris/articles/named_pipes.html

Comments

1

I think you want coprocesses. In bash 4 there is a new builtin "coproc".

See here for examples:

http://tldp.org/LDP/abs/html/bashver4.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.