Tuesday, 7 April 2009

Script to take picture at boot and send online

Ive made this script to take an picture on every linux boot and send online, just in case someone steel my laptop. (You must specify host, username and pass)

Note: it uses xawtv streamer tool and ftp to send the images to ftp server
If there's no internet connection the script stays on standby waiting for internet connections goes up, then sends. (I have made from some examples, and c# application for windows to do the same, maybe i can post here the application and code)


For example you can add this to startup:
in /etc/conf.d/local.start add sh take_pic_send_online.sh & &>/dev/null
/etc/inid.d/local restart :)

#!/bin/sh

dt=`date +%y%m%d-%T`
filepath="/tmp/"
filename="boot-"$dt".jpeg"
file=$filepath$filename

streamer -c /dev/video0 -b 32 -o $file

hostname="ftp.XXXX.XXX"
username="USERNAME"
password="PASSWORD"

while true
do

if eval "ping -c 1 www.google.com"; then
break;
else
sleep 15;
fi

done

echo -e "***FTP SERVER DOWNLOAD SPEED***\n" >> /tmp/speedtest.log
ftp -inv $hostname >> /tmp/speedtest.log <<>
quote USER $username
quote PASS $password
cd boot
binary
lcd $filepath
put $filename
bye

EOF
rm $file /tmp/speedtest.log

No comments:

Post a Comment