gnuplotを自動的に実行したいと思いました。
whichコマンドの登場。
$ which gnuplot
/usr/bin/gnuplot
発見。
test.gnuplot
set terminal png
set output 'test.png'
plot x
y=xなんてplotしてどうするの>オレ
ターミナルから実行してみる
$ chmod +x test.gnuplot
$ ./test.gnuplot
無事にtest.pngというファイルができました。
めでたし。めでたし。
ハマった箇所。
これに気づくのに結構な時間がかかった。
#!/bin/bash
とか、
#!/opt/local/bin/perl
みたいにbashやperlのスクリプトを書いているときには、一番上にスクリプトのパスを記述していたんだけど。
なんか、盲点だった。気づいてみれば、普通なんだけど。
ちなみに
test.cat
#!/bin/cat
1
2
3
とか、スクリプトを書いて、実行してみた。
$ chmod +x test.cat
$ ./test.cat
#!/bin/cat
1
2
3
こんなことも、できるんですね。
使い道は今の所、ないですけど。