pipe output to stdin of a process and capture output

조회 수: 13 (최근 30일)
Brandon Barker
Brandon Barker 2013년 3월 16일
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).

채택된 답변

Walter Roberson
Walter Roberson 2013년 3월 16일
편집: Walter Roberson 2013년 3월 16일
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개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by