是否可以将 "print" gnuplot 的输出直接输出到 STDOUT?
Is it possible to "print" gnuplot's output directly to STDOUT?
我正在使用名为 gnuplot-iostream 的 third-parter 实用程序在 Web 应用程序的 back-end 中从 C++ 调用 gnuplot。该 Web 应用程序是在 CGI 下执行的,因此进入 STDOUT
的任何内容都是浏览器的结果。在这种情况下,Web 请求将针对图像本身,因此输出将以一些 HTTP headers 开头,包括 image/png
的 Content-Type
。
而不是 having gnuplot write to a temporary file, then read that file back into memory and stream its contents to STDOUT
,我希望能够通过 STDOUT
直接通过管道传输 GNUPlot 的输出,但我看不出有什么方法可以让 gnuplot 做除了写入图像以外的任何事情磁盘上的文件,或打开 X11 window.
这可能吗?
写入命名管道?你用 mkfifo
?
做的那种
我使用了以下结合了 mkfifo
和 mktemp
的愚蠢技巧:
FOO=$(mktemp -d)
mkfifo "$FOO/bar"
# pipe some stuff through "$FOO/bar"
rm -r "$FOO"
请记住,一旦您拥有同一个命名管道,没有什么能阻止您使用它。
在 gnuplot 脚本中,不要将输出文件设置为将图像内容定向到标准输出:
gnuplot -e 'set terminal pngcairo; plot x' > myfile.png
我不太确定,那必须如何与 gnuplot-iostream 集成。
我正在使用名为 gnuplot-iostream 的 third-parter 实用程序在 Web 应用程序的 back-end 中从 C++ 调用 gnuplot。该 Web 应用程序是在 CGI 下执行的,因此进入 STDOUT
的任何内容都是浏览器的结果。在这种情况下,Web 请求将针对图像本身,因此输出将以一些 HTTP headers 开头,包括 image/png
的 Content-Type
。
而不是 having gnuplot write to a temporary file, then read that file back into memory and stream its contents to STDOUT
,我希望能够通过 STDOUT
直接通过管道传输 GNUPlot 的输出,但我看不出有什么方法可以让 gnuplot 做除了写入图像以外的任何事情磁盘上的文件,或打开 X11 window.
这可能吗?
写入命名管道?你用 mkfifo
?
我使用了以下结合了 mkfifo
和 mktemp
的愚蠢技巧:
FOO=$(mktemp -d)
mkfifo "$FOO/bar"
# pipe some stuff through "$FOO/bar"
rm -r "$FOO"
请记住,一旦您拥有同一个命名管道,没有什么能阻止您使用它。
在 gnuplot 脚本中,不要将输出文件设置为将图像内容定向到标准输出:
gnuplot -e 'set terminal pngcairo; plot x' > myfile.png
我不太确定,那必须如何与 gnuplot-iostream 集成。