Reputation: 2458
With Gnuplot it is possible to pipe output into another process, e.g.:
set output "| cat >&2"
This line redirects the plot output into file descriptor "2".
However, in this case all the Output data goes through cat
. How can I send the output directly to a file descriptor of my choice?
Upvotes: 2
Views: 1576
Reputation: 3764
To avoid cat
, you can use
set output '/dev/fd/2'
This requires that the anonymous pipe has been opened before. Since 2
is stderr
, this is usually the case.
The same holds for /dev/fd/1
, which is stdout
and seems to be the default, i.e. set output '/dev/fd/1'
is the same as set output
.
But for /dev/fd/3
, the pipe needs to be setup before. E.g. one needs 3>tmp.ps
on the command line:
gnuplot -e "set terminal post; set out '/dev/fd/3'; plot sin(x)" 3>tmp.ps
Otherwise it would result in line 0: cannot open file; output not changed
system error: No such file or directory
. Of course set out 'tmp.ps'
would be even more simple.
Upvotes: 1
Reputation: 48430
You can remove the set output
completely from your gnuplot script. Then the output is written to stdout
, which you can then redirect:
gnuplot -e "set terminal pngcairo; plot sin(x)" >&2
Upvotes: 2