gnuplotを自動的に実行したい

gnuplotを自動的に実行したいと思いました。

gnuplotのパスを確かめる。

whichコマンドの登場。

$ which gnuplot
/usr/bin/gnuplot

発見。

スクリプトを書く。

test.gnuplot

#!/usr/bin/gnuplot
set terminal png
set output 'test.png'
plot x

y=xなんてplotしてどうするの>オレ

ターミナルから実行してみる

$ chmod +x test.gnuplot
$ ./test.gnuplot

無事にtest.pngというファイルができました。
めでたし。めでたし。

ハマった箇所。

#!/usr/bin/gnuplot

これに気づくのに結構な時間がかかった。

#!/bin/bash

とか、

#!/opt/local/bin/perl

みたいにbashperlスクリプトを書いているときには、一番上にスクリプトのパスを記述していたんだけど。
なんか、盲点だった。気づいてみれば、普通なんだけど。

ちなみに
test.cat

#!/bin/cat

1
2
3

とか、スクリプトを書いて、実行してみた。

$ chmod +x test.cat
$ ./test.cat
#!/bin/cat

1
2
3

こんなことも、できるんですね。
使い道は今の所、ないですけど。