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

📄 imagegetcommand.txt

📁 这是《嵌入式linux-硬件、软件与接口》一书对应的所有linux方面实例的源代码
💻 TXT
字号:
#!/bin/bash
# imageGetCommand 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.
#
# imageGetCommand
# imageGetCommand is a CGI script. A field target board
# sends an HTTP request to retrieve an complete image capture command.
# For Project Trailblazer, we are using the vgrabbj program. This
# script performs a query for location description using the target's
# IP address contained in the $REMOTE_ADDR variable. The script then
# returns a completely formatted bash command that includes a unique
# filename for the capture output and an overlay parameter that contains
# location, current time and date information.
#
# The command also contains a sleep statement to pause the script main
# loop running on the target. The sleep value could be changed dynamically
# based on time of day. Here it is set to 300 seconds or 5 minutes.
DELAY=300
#
# This script also logs this request in the Trailblazer database image 
# table. Web queries use these image entries to find the latest image 
# from a location.
#
# Here's the header/content blank separation line required by Apache
echo

# get the last octet of the target's IP address
location=`echo $REMOTE_ADDR | cut -f 4 -d '.'`

# query the database for the target boards location description
locationdes=`echo "SELECT description from locations where \
             location = $location;" | \
             mysql trailblazer --user=trailblazer --pass=tb --silent`

# output the image command and the sleep statement
filename=`printf "%03d-%s.jpg" $location \`date +%Y%m%d%H%M%S\``
printf "vgrabbj -e -i vga -f /tmp/$filename" 
printf " -p \"%s - %s\" -T 20 -a 5 -m 50; sleep $DELAY\n" \
       "$locationdes" "`date +%A\,\ %D\,\ %r`"

# Here's an example output
# vgrabbj -e -i vga -f /tmp/030-20020102000919.jpg -p \
# "Lift 1 Base - Wednesday, 01/02/02, 12:09:19 AM" -T 20 -a 5 -m 50

# Here are the vgrabbj command line options used
#-e      Enables the timestamp
#-i vga  Sets the image size to 640x480
#-f      Writes to an output file instead of to stdout
#-p      Defines the overlay in timestamp format
#-T      Sets the overlay font size
#-a      Sets the overlay alignment on the image
#-m      Sets the overlay blending with the original image

# log this query
echo "INSERT INTO images (location,filename) \
      VALUES ($location,\"$filename\");" | \
      mysql trailblazer --user=trailblazer --pass=tb

⌨️ 快捷键说明

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