これは、グラフを生成して組み合わせるための私のスクリプトです。問題は、入力を与えてターミナルでファイルを実行すると、ダンプファイルにnullが表示されることです。mysqlコマンドも実行されていないと思います。コマンド自体にdatetime1、datetime2、moteidを入力すると、Mysqlコマンドは正常に機能します。mysqlクエリでどこが間違っているのかわかりませんでした。
datetime1=$1
datetime2 = $ 2 moteid = $ 3
echo " \\documentclass[a4paper,12pt]{article} \
\\usepackage{graphicx} \
\\usepackage{subfigure} \
\\begin{document} \
\\begin{center} \
\\begin{Large} \
\\textbf{ A Network Management System} \\\ \
\\end{Large} \
\\end{center} \
\\vspace{5mm} \
{\bf Report }" > report.tex
flag=0
count_null=0
echo "\\begin{center} \
{\bf Report generated } \
\\end{center} " >> report.tex
mysql -u root -e "SELECT (b.l2framessent - a.l2framessent) AS netl2framessent,(b.Frames_Drop-a.Frames_Drop) AS netframesdrop,(b.ETX - a.ETX) AS netetx,CONVERT(endOfInterval*500, DATETIME) endOfInterval FROM (SELECT datetime DIV 500 startOfInterval,l2framessent,Frames_Drop,ETX FROM Statistics3,(SELECT MIN(datetime) mindate FROM Statistics3 WHERE ipaddress=\"$moteid\" AND datetime BETWEEN \"$datetime1\" AND \"$datetime2\" GROUP BY datetime DIV 500) b WHERE ipaddress=\"$moteid\" AND datetime = mindate) a, (SELECT datetime DIV 500 endOfInterval, l2framessent,Frames_Drop,ETX FROM Statistics3, (SELECT MIN(datetime) mindate FROM Statistics3 WHERE ipaddress = \"$moteid\" AND datetime BETWEEN \"$datetime1\" AND \"$datetime2\" GROUP BY datetime DIV 500) b WHERE ipaddress = \"$moteid\" AND datetime = mindate) b WHERE endOfInterval = startOfInterval+ 1 ;" >> dump
sed '1d' dump
##### ETX ######
echo "reset \
set terminal png \
set xdata time \
set timefmt \"%H:%M:%S\" \
set xlabel \"Time\" \
set ylabel \"netetx\" \
set title \"ETX\" \
set grid \
plot \"dump\" using 4:3 title \"ETX\" " >> etx.sh
gnuplot etx.sh > etx.png
#L2 Frames Sent
echo "reset \
set terminal png \
set xdata time \
set timefmt \"%H:%M:%S\" \
set xlabel \"Time\" \
set ylabel \"netL2Framessent\" \
set title \"L2 Frames Sent\" \
set grid \
plot \"dump\" using 4:1 title \"L2 Frames Sent\" " >> frames.sh
gnuplot frames.sh > frames.png
#Frames Drop
echo "reset \
set terminal png \
set xdata time \
set timefmt \"%H:%M:%S\" \
set xlabel \"Time\" \
set ylabel \"netframesdrop\" \
set title \"L2 Frames Drop\" \
set grid \
plot \"dump\" using 4:2 title \"L2 Frames Drop\" " >> framesdrop.sh
gnuplot framesdrop.sh > framesdrop.png
## TEX FILE GENERATION ####
echo "\\begin{figure}[h] \
\\begin{center} \
\\subfigure[ETX]{\label{fig:edge-1a}\includegraphics[width=2.6in,height=2.5in]{etx.png}} \
\\hspace{1mm} \
\\subfigure[L2 Frames Sent]{\label{fig:edge-1b}\includegraphics[width=2.6in,height=2.5in]{frames.png}} \
\\end{center} \
\\label{fig:edge} \
\\end{figure} \
\\begin{figure}[h] \
\\begin{center} " >> report.tex
echo "\\subfigure[L2 Frames Drop]{\label{fig:edge-2a}\includegraphics[width=2.5in,height=2.5in]{framesdrop.png}} \
\\hspace{3mm} >> report.tex
\\end{center} \
\\label{fig:edge} \
\\end{figure} \
\\clearpage " >> report.tex
echo "\\end{document} " >> report.tex
pdflatex report.tex > /dev/null
私が与えた出力を実行するためのターミナルで、sh plot.sh "2012-09-25 15:45:00" "2012-09-2918:45:00""5"そして出力は
plot "dump" using 4:3 title "ETX"
^
"etx.sh", line 12: warning: Skipping data file with no valid points
plot "dump" using 4:3 title "ETX"
^
"etx.sh", line 12: x range is invalid
plot "dump" using 4:1 title "L2 Frames Sent"
^
"frames.sh", line 12: warning: Skipping data file with no valid points
plot "dump" using 4:1 title "L2 Frames Sent"
^
"frames.sh", line 12: x range is invalid
plot "dump" using 4:2 title "L2 Frames Drop"
^
"drop.sh", line 12: warning: Skipping data file with no valid points
plot "dump" using 4:2 title "L2 Frames Drop"
^
"drop.sh", line 12: x range is invalid
RUN SUCCESSFUL (total time: 154ms)
その代わりにこのmysqlクエリを指定すると、正常に機能します
mysql -u root -e "SELECT (b.l2framessent - a.l2framessent) AS netl2framessent,(b.Frames_Drop-a.Frames_Drop) AS netframesdrop,(b.ETX - a.ETX) AS netetx,CONVERT(endOfInterval*500, DATETIME) endOfInterval FROM (SELECT datetime DIV 500 startOfInterval,l2framessent,Frames_Drop,ETX FROM Statistics3,(SELECT MIN(datetime) mindate FROM Statistics3 WHERE ipaddress='moteid5' AND datetime BETWEEN '2012-09-25 15:45:00' AND '2012-09-25 18:45:00' GROUP BY datetime DIV 500) b WHERE ipaddress='moteid5' AND datetime = mindate) a, (SELECT datetime DIV 500 endOfInterval, l2framessent,Frames_Drop,ETX FROM Statistics3, (SELECT MIN(datetime) mindate FROM Statistics3 WHERE ipaddress = 'moteid5' AND datetime BETWEEN '2012-09-25 15:45:00' AND '2012-09-25 18:45:00' GROUP BY datetime DIV 500) b WHERE ipaddress = 'moteid5'AND datetime = mindate) b WHERE endOfInterval = startOfInterval+ 1 ;" >> dump