473,322 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Emulating pipes

Does anyone know of a way I can make a program read/write from
stdin/stdout so that I can chain it with other commands and
interact with it from python? Unfortunately it's third party
software and thus can't be changed to do so. The program has
to be invoked 'program input.file output.file'. I would like
to do something like 'otherprog | program stdin stdout |
anotherprog' to take advantage of of the multiprocessor
environment I'm on.

I looked at the pipes module and it's really nice.
Unfortunately it breaks the command up and writes temp files
to overcome this, so it won't use multiple processes.

Any suggestions would be greatly appreciated.
I'm running Python 2.2.3 on a 24 processor IRIX64 6.5.14f.

Thanks,
Brian
Jul 18 '05 #1
1 1366
On Thu, 29 Jul 2004 br****@temple.edu wrote:
Does anyone know of a way I can make a program read/write from
stdin/stdout so that I can chain it with other commands and interact
with it from python? I would like to do something like 'otherprog | program stdin stdout |
anotherprog' to take advantage of of the multiprocessor environment I'm
on.


There are a few command-line solutions to this problem:

IRIX may or may not provide the /dev/stdin and /dev/stdout devices. These
were introduced (?) by Linux as a means to access the current process's
stdin and stdout file descriptors, respectively:

$ otherprog | program /dev/stdin /dev/stdout | anotherprog

If IRIX doesn't provide this, and you are using bash (or something based
on it), you could use process substitution. This is a magic construction
that allows you to use programs where files are expected:

$ program <(otherprog) >(anotherprog)

If that fails, your last resort is to use named FIFOs (this is one way
process substitution is implemented, the other being similar to the
first solution):

$ mkfifo tmpfifo1
$ mkfifo tmpfifo2
$ otherprog > tmpfifo1 & program tmpfifo1 tmpfifo2 & anotherprog < tmpfifo2

Hope this helps.

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Christian Hammers | last post by:
Hello I would like to call a unix shellscript from within a PHP script and - write data to its STDIN - read data from its STDOUT *and* STDERR - get its exit code afterwards proc_open seems...
2
by: Bart | last post by:
Hi there, Since you've all told me that frames ar evil, I'm planning to disguard frames in favour of CSS "pseudo-frames" for my personal website. While trying to "emulate frames" (that is I...
5
by: Peng Yuan Fan | last post by:
Hi, sorry if you found I have multi posted in different groups. It didn't appear in that group. I am trying to write an automated testing program with CxxTest, which in turn needs to talk to gdb...
5
by: glenn.owens | last post by:
In the process of doing some routine monitoring/clean-up we've discovered that several (many?) users are apparently set to access our SQL Server 2000 database instances via the Named Pipes...
9
by: Hans J?rg Brinksmeyer | last post by:
Hi, does anyone have an idea for this problem: I use anonymous pipes to steer a console program under Win2000 with a second 'steering aplication'. The stdin and output are redirected to...
5
by: Stephan Schaem | last post by:
How does one write an unmanaged function that perform this functionality? In short I want to turn off/on visual style in my app... Thanks, Stephan PS: two people have been looking for...
7
by: webmaster | last post by:
Sorry if this sounds naive, but I need to know how to create a two-way pipe between my Objective-C MacOSX program and another process, like perl, for example. Is there a simple way to do this in C,...
3
by: ZhukovL | last post by:
I'm having some trouble implementing the handling of multiple pipes in a shell I'm writing. I was hoping someone could point me in the right direction because I really cant see where I'm going...
7
by: andrewb | last post by:
Hi all, Having some trouble using named pipes and Visual Basic .NET and would appreciate and help you could offer. Essentially I am trying to develop a simple client/server application that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.