Or maybe a better question is - how can I get a
stdin stream? I need to run on Linux.
I did look at Reading from STDIN, or: how to pipe data into Mathematica, but that talks about text data. I need to import an image, sent to standard output by another program.
According to Mathematica documentation, there is no pre-defined standard input stream, there's only
$Output, which is standard output, and
$Input, which is the script being executed. There are only 2 functions that read from standard input in the expected way -
Input, which tries to read a Mathematica expression, and
InputString, which tries to read a string till it gets a newline. Neither of these is good for reading non-text data.
What I would prefer to do is read from a stream, preferably using
Import. I want to use this Mathematica script in a shell script, and pipe data to it.
Import[OpenRead["/dev/stdin"]], but this only seems to work if I have an actual file on disk and I redirect input using
<. It doesn't work if I pipe data to the Mathematica script.