temperaturereport.txt

来自「这是《嵌入式linux-硬件、软件与接口》一书对应的所有linux方面实例的源代」· 文本 代码 · 共 47 行

TXT
47
字号
#!/bin/bash
# temperatureReport 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.
#
# temperatureReport 
# temperatureReport is a bash script that executes on a target board
# with an external temperature sensor and its module loaded. Loading
# the module, such as LM70_x86.o from Chapter 10 creates the
# /proc/trailblazer/temperature file. This script gets the current
# temperature from /proc/trailblazer/temperature, forms an HTTP GET
# query using temperatureRecord with the temperature as the 
# parameter. This query is piped into nc which makes a TCP connection
# to tbdev1's apache HTTP server on port 80. nc is configured with
# the -w flag which sets a connection timeout. If tbdev1's apache 
# server doesn't answer, this script will continue to operate.
#
# Call this from inittab using the respawn option as in
# T3:23:respawn:/usr/bin/temperatureReport
# If temperatureReport should die, init will start it again
#
# loop forever
while [ 1 ]
do

# get temp
 temperature=`cat /proc/trailblazer/temperature`

# form the query and pipe to nc
 echo "GET /cgi-bin/temperatureRecord?$temperature" \
      | nc -w 10 192.168.1.11 80

# print out temperature
 echo $temperature

# pause for 5 minutes
 sleep 300
done

⌨️ 快捷键说明

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