Today I tried using Mathematica's plotting capabilities to display the output of a C++ program. This made me wonder whether it is possible to somehow tell a Mathematica script to read from STDIN and then do something with that, a la
#/usr/local/bin/MathematicaScript -script
(* Mathematica plotting script *)
data = ReadStream["STDIN"];
plot = ListPlot[data];
Export[plot, ...];
which can then be used like
./cppDataGenerator | mathematicaPlotScript
However, I couldn't find much on that in the documentation, the entries always focus on output or string streams, and trial and error didn't yield a result either.
So the question is: How can I make a Mathematica script listen on the standard input?
Input["!cat","String"]or something similar? Perhaps also try"!cat -". Note this is untested and just a guess!! – Szabolcs Mar 24 '12 at 16:26