这是我用于生成图表并将它们组合起来的脚本。问题是当我给出输入并在终端中运行文件时,它在转储文件中显示为空。我认为它也没有执行 mysql 命令。如果我在命令本身中输入 datetime1、datetime2 和 moteid,Mysql 命令工作正常。我在 mysql 查询中找不到我出错的地方
datetime1=$1
日期时间2=$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-29 18: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