0

This is my script for generating graphs and combining them. The problem is when i give the inputs and run the file in terminal,it is showing null in the dump file.I think its not executing the mysql command also. Mysql command is working fine if i give the inputs datetime1,datetime2 and moteid in the command itself.I couldnt find where i am going wrong in the mysql query

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

In the terminal to run the output i gave, sh plot.sh "2012-09-25 15:45:00" "2012-09-29 18:45:00" "5" and the output is

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)

If i give this mysql query instead of that,its working fine

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

2 Answers 2

1

The command:

sed '1d'

isn't given an input file, so it's reading from standard input. So it's waiting for you to type something. I suspect you meant to pipe the output of mysql to it, so it should be:

mysql -u root -e "SELECT ..." | sed 1d >> filename
Sign up to request clarification or add additional context in comments.

5 Comments

mysql output is netl2framessent netframesdrop netetx endOfInterval 29 1 0 2012-09-25 17:50:00 30 1 0 2012-09-25 17:55:00 30 1 0 2012-09-25 18:05:00 29 1 0 2012-09-25 18:10:00 29 1 0 2012-09-25 18:15:00 29 1 0 2012-09-25 18:20:00.I need to delete the first line.Which filename i have to give
What was the point of that comment? I told you why the script is stopping: the sed command needs input. If that's not the problem, I suggest you put set -x at the top of the script so you can see what it's doing as it runs.
Ok, I understood what you said
I gave the file name.I got the mysql output without first line.But after that the output is Warning: empty x range [72000:72000], adjusting to [71280:72720] Warning: empty x range [72000:72000], adjusting to [71280:72720] Warning: empty x range [72000:72000], adjusting to [71280:72720] reset set terminal png ^ "framesdrop.sh", line 1: warning: expected optional axis name reset set terminal png ^ "framesdrop.sh", line 1: ';' expected RUN FAILED (exit value 70, total time: 460ms)
Sounds like there's something wrong with the data you're feeding to gnuplot. I don't know much about that, and don't see where you're creating its input file in the script. BTW, don't try to put long messages in comments, they lose all their formatting. Edit your question and add them there.
0

Instead of 5 at mote,i have to give moteid5.Its not showing any error now

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.