View Single Post
Posts: 167 | Thanked: 204 times | Joined on Jul 2010
#5
Crude, bleeding edge proof of concept for waiting on camera images using inotifywait. Requires inotify-tools.

It currently waits on a close-after-writing in the camera directory, lists the number of images and the filename of the newest. It should be fairly easy to trigger whatever desired upload actions from there.

Code:
maemo:~# cat /usr/bin/camwatch
#!/bin/bash

WATCH_PATH="/media/mmc1/DCIM"
FILENAMES="*.jpg"
WATCH_COUNT=0
COUNTER=0
declare -i WATCH_COUNT;
declare -i COUNTER;
inotifywait -m --format '%f' -e close_write $WATCH_PATH | while read FILE

do

WATCH_COUNT=$WATCH_COUNT+1;

COUNTER=$(ls -1 $WATCH_PATH/$FILENAMES | wc -l);


NEWEST=$(ls -t1 $WATCH_PATH | head -n 1);

echo "$COUNTER $NEWEST";

done
and subsequently a quick hack to upload the newly-created image via curl... in this case, to a WebDAV folder. Working for me...

Code:
#!/bin/bash

WATCH_PATH="/media/mmc1/DCIM"
FILENAMES="*.jpg"
WATCH_COUNT=0
declare -i WATCH_COUNT;
inotifywait -m --format '%f' -e close_write $WATCH_PATH | while read FILE
do
WATCH_COUNT=$WATCH_COUNT+1;
NEWEST=$(ls -t1 $WATCH_PATH | head -n 1);
curl -T $WATCH_PATH/$NEWEST http://<user:pass>@files.memotoo.com/webFolder/DCIM/;
echo "uploaded $WATCH_PATH/$NEWEST";
done

Last edited by magick777; 2013-06-12 at 11:34.
 

The Following 3 Users Say Thank You to magick777 For This Useful Post: