问题: (开机运行的时候找不到camshot程序,所以我给camshot加上了完全路径。)
最主要参考了奶牛的博客, 谢谢啦:
http://www.nenew.net/linux-security-arch-linux-auto-mail-notification.html
http://www.nenew.net/linux-camera-shot-camshot.html
结合我转载的Mutt发送邮件,camshot 在命令行下拍照以及让脚本开机运行。
可以做出一个很简单的开机监控应用。
capture.sh 内容如下:
#!/bin/sh
#chkconfig:23456 99 05
#send email to $dst \
#with $subject $attach
#variable setting
dst=chj90220@126.com
subject=`date`
subject="$subject: someone startup you computer"
content="someone startup you computer.His/Her image is in attachment.please check"
attach=date_$$.bmp
bmppipe="pipefile"
logout=/run/media/huntinux/F/linux-space/log/capturelog.out
logerr=/run/media/huntinux/F/linux-space/log/capturelog.err
# get picture through camera
/run/media/huntinux/F/huntinux_bin/camshot-1.0/camshot-read-only/camshot -W 320 -H 240 -p ./$bmppipe 1>$logout 2>$logerr &
sleep 5
cat $bmppipe >$attach
# send picture to email $dst
echo "$content" | mutt "$dst" -s "$subject" -a "$attach"
# close camshot
kill `ps aux |grep camshot|grep -v grep|awk -F " " '{printf $2}'`
#rm -rf $attach
exit 0
测试成功后,将其开机自动启动即可。
# chmod +x captuer.sh
# cp capture.sh /etc/init.d/
# chkconfig --add capture.sh
# chkconfig --list capture.sh
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
capture.sh 0:off 1:off 2:on 3:on 4:on 5:on 6:on
重启即可在邮箱看到邮件。看看里面有没有照片。哈哈