I want to create something file-like (that can be read like a common file), which everytime it is read, it gets its output from a command.
For instance, if I do
echo $RANDOM > test,
then I can call
cat test and it will display the generated random number.
Except that I would need that everytime I call
cat test (or read it any other way), my generator command is called (
echo $RANDOM in my example, but actually it will generate more data -- around 1kb).
I think the best bet would be to create some kind of device special file / device driver? What I need is indeed similar to /dev/zero or /dev/random. Is it possible to create it simply? Using standard gnu/sh library would be ideal?
Thanks in advance for any hint!