📄 imagegetcommand.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 Apacheecho# get the last octet of the target's IP addresslocation=`echo $REMOTE_ADDR | cut -f 4 -d '.'`# query the database for the target boards location descriptionlocationdes=`echo "SELECT description from locations where \ location = $location;" | \ mysql trailblazer --user=trailblazer --pass=tb --silent`# output the image command and the sleep statementfilename=`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 queryecho "INSERT INTO images (location,filename) \ VALUES ($location,\"$filename\");" | \ mysql trailblazer --user=trailblazer --pass=tb
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -