pipe output to stdin of a process and capture output
14 views (last 30 days)
Show older comments
In UNIX, I'd simply run the command like so: cat file_to_stdin | ./minDisj other_input_file > output_file.txt
What I'd like to do is run this in MATLAB, with the text normally contained in file_to_stdin being input directly from MATLAB (e.g. I have a cell array I'd like to print in to the stdin) and then capture and process the output that would come from minDisj's stdout.
The system command seems capable of doing everything but directing chosen MATLAB output to the stdin of the process.
Other that potentially using named pipes (fifos), is there an easier alternative?
I can recompile minDisj above to handle its input in other ways, but I'd prefer not to print out to a file first, as this is both messy and slow, and dealing with fifos seems to be overkill (but may be necessary).
0 Comments
Accepted Answer
Walter Roberson
on 16 Mar 2013
Edited: Walter Roberson
on 16 Mar 2013
MATLAB has no facility for interactively piping. You need to write to a named pipe, or write to a file and redirect from the file, or write a mex routine that will handle creating the pipes for you. (Caution: if you do that, watch out for MATLAB liking to handle its own buffering.
0 Comments
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!