System information
Shell Script Examples
Axis Communications AB provides NO support for application development of any kind. The information
here is provided "as is", and there is no guarantee that any of the examples shown will work in your
particular application.
Revision 1.02 October 2002 77
# Start the buffers as specified by the parameters
bufferd -start -buffername $2 -snapshot -pre 1 -predelay "$delay" -uri
ftp://jpg/"$sources"/"$image_format".jpg -format snapshot_%y%m%d_%H%M%S.jpg
# Set the counter variable according to the file /tmp/counter
if [ -e /tmp/counter ]; then
current_counter=`cat /tmp/counter`
else
current_counter=001
fi
session_time=0 # Time during this session
expr $time \* 1000 > /tmp/C
time=`cat /tmp/C`; rm /tmp/C # Convert the time in milliseconds
source_file="/tmp/$2" # Path of the directory of the image
while[!-d$source_file ]; do # Wait the creation of the directory
done
cd $source_file # Change to the directory specified above
exit=0
while [ $exit=0];do#While no errors appeared
# If the time to stay in the script has been reach
if [ $session_time -ge $time ]; then
if [ $time -ne -1000 ]; then # If not infinite
exit=1 # Exit the script
fi
# Calculate the session time
else
expr $session_time + $delay > /tmp/C
session_time=`cat /tmp/C`; rm /tmp/C
fi
if [ $exit -ne 1 ]; then
# Path of the directory of the image
source_file="/tmp/$2"
OK=0 # Image not found
# While the image has not been found
while [ $OK=0];do
tmp=`ls` # List the file on the directory
# If there is a file inside
if[!-z$tmp ]; then
# Do not take an incomplete image
if [ $tmp != tmpimage ]; then
OK=1 # The image has been found
# Path of the image
source_file=$source_file"/"$tmp
fi
fi
done
# If the uploaded file must be sequenced for an index
if [ $suffix = sequenced_max ]; then
# Modify the path of the new file
source_file="/tmp/$2"/"snapshot_$current_counter".jpg
# Rename the file
cp $tmp $source_file; rm $tmp
# Increment the current counter
expr $current_counter+1>/tmp/counter
current_counter=`cat /tmp/counter`
# Change this current counter on 3 digit if necessary
if [ $current_counter -lt 10 ]; then