On Mon, Mar 21, 2011 at 9:28 PM, Binand Sethumadhavan binand@gmail.comwrote:
2011/3/21 Rony gnulinuxist@gmail.com:
figure is not constant. One way out is that every day the %s figure is generated at exactly 10:00 and this is then 'diff'ed with the user's attendance time in %s. This is then divided by 60.
You don't need to do that. You can simply do:
late=$(( `date '+%s'` - `date '+%s' -d 'today 10am'` ))
And then convert $late to any format you want.
Thanks for the tip. I am pasting my code below which works. I will now tweak it with your code above. In the code below, 'cat ten' refers to the file 'ten' which is supposed to be updated everyday at 10.00 AM with date +%s but now won't be needed. The script was made and tested on my netbook and uses the in-built camera. The result is a tiny stamp sized photo uses only 1 KB of space. Cheap bio-metrics.
#!/bin/bash DATE=$(date) CUR=$(date +%s) REF=$(cat ten) streamer -c /dev/video0 -b 16 -q -o testuser.jpeg convert testuser.jpeg -resize 60x40 testuser.jpeg DIFF=$(( $CUR - $REF )) MIN=$(($DIFF/60)) echo " $DATE, Testuser, $MIN," >> Testuser_log.csv exit