Capture bash script

The final piece to get my eeepc to take pictures periodically was to wrap up the vlc (see Webcam capture using vlc) and crontab (see Crontab) stuff in a bash script. This is a way of making scripts for the Unix shell which is default on many distributions and certainly on Ununtu.

This is the script I entitled capture.sh, put in my bash_scripts folder and referred to with the crontab:

#!/bin/bash

cd $HOME/captures

D1=`date +%Y-%m-%d`
D2=`date +%Y%m%d_%H-%M_`

# If the date directory does not exist, create it
if [ ! -d $D1 ] ; then
mkdir -p $D1
fi

#cd to this new directory
cd $HOME/captures/$D1

# capture images using vlc
cvlc v4l2:// -V image --image-out-ratio 150 --image-out-prefix $D2 --run-time 50 vlc://quit 2> /dev/video0

This entry was posted in Bash scripting, Code, Linux, Webcam. Bookmark the permalink.