⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 temperaturegetplot.txt

📁 这是《嵌入式linux-硬件、软件与接口》一书对应的所有linux方面实例的源代码
💻 TXT
字号:
#!/bin/bash
# temperatureGetPlot v1.0 12/31/01
# www.embeddedlinuxinterfacing.com
#
# The original location of this code is
# http://www.embeddedlinuxinterfacing.com/chapters/12/
#
# Copyright (C) 2001 by Craig Hollabaugh
#
# This program is free software; you can redistribute it and/or modify
# it however you want.
#
# temperatureGetPlot 
# temperatureGetPlot is a CGI script. A web service sends an HTTP 
# request with a Trailblazer location number as a parameter. 
# Apache calls this script setting the $QUERY_STRING variable 
# to the location number. This script forms a SELECT statement 
# that returns a table of record temperatures for the location. The
# script then calls gnuplot to plot these temperatures, creating
# and outputing a png image.
#
# Here's the Content-type line to tell the browser that this reply
# is a png image.
echo Content-type: image/png 

# Here's the header/content blank separation line required by Apache
echo

# Set the location
location=$QUERY_STRING

# Form the SELECT statement and pipe it to mysql.
# You have to login in to mysql as trailblazer with
# password tb because apache will execute this script as 
# user www-data not root. Redirect the output to a temp file.
echo "SELECT timestamp, temperature from temperatures where \
      location = $location order by timestamp asc;" | \
      mysql trailblazer --user=trailblazer --pass=tb --silent > /tmp/tempdata


# Query the database for the location description for use in plot title
locationdes=`echo "SELECT description from locations where \
             location = $location;" | \
             mysql trailblazer --user=trailblazer --pass=tb --silent`

# Execute gnuplot, send various commands to set up plot, then plot
# the temperatures from the temp data file. See http://www.gnuplot.vt.edu/
# for more gnuplot information.
/usr/bin/gnuplot << ENDOFINPUT
set terminal png color 
set xdata time
set timefmt "%Y%m%d%H%M%S"
set format x "%m/%d\n%H:%M"
set nokey
set title "$locationdes Temperature"
set ylabel "Temperature (F)"
set xlabel "Date - Time"
set grid
set rmargin 5
plot "/tmp/tempdata" using 1:2 with linespoints
ENDOFINPUT





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -