Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-18-2004, 01:54 AM   #1
LQ Newbie
Registered: Sep 2004
Posts: 2

Rep: Reputation: 0
piping both ways?

hello there,

this is perhaps a foolish question, but i'm having trouble getting my head around the problem;
i know that you can pipe the output of command1 to the input of command2 like this:

command1 | command2

but how would i go about having it send the output of command2 (which would usually go to stdout) back to command1 (which would be stdin), so that the programs can basically talk to each other?
Old 09-18-2004, 02:31 AM   #2
LQ Guru
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
command1 | command2 | command1
Old 09-20-2004, 05:14 AM   #3
Senior Member
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 63
No. That wouldn't work because the second "command1" is not the same instance as the first one.
I think the solution here is to use fifos.

Something like that (probably inside a third "controler" script):
mkfifo /tmp/from1to2
mkfifo /tmp/from2to1

command1 </tmp/from2to1 >/tmp/from1to2 &
command2 </tmp/from1to2 >/tmp/from2to1

rm -f /tmp/from1to2 /tmp/from2to1
Old 09-20-2004, 07:10 PM   #4
LQ Newbie
Registered: Sep 2004
Posts: 2

Original Poster
Rep: Reputation: 0
hey, thanks guy! i think that's just what i needed to know!

the thing i love about linux is that whenever i have a problem, i end up learning more about the system or computers themselves.

thanks for your help


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with piping mijohnst Linux - General 7 10-21-2005 04:14 PM
piping /forking geminigal Programming 3 04-10-2005 09:49 PM
Unzip + Piping iago Linux - Software 2 11-17-2004 02:11 PM
piping between backends robhargreaves Programming 1 05-01-2004 07:01 AM
Piping question OtisLinux Linux - Software 1 02-12-2004 01:38 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration