linux - modifying a time lapse bash script for raspberry pi - crashes before 10 Am -
i got bash script online uses raspberry pi's camera module take photos @ specified rate specified timeframe. can't seem run script before 10 because can't add timeframe time (in 24 hour) because has 0 in front of number. tried adding # in front of variable other posts said pi spits out syntax error. i'm new bash.
code:
#!/bin/sh if [ ! -n "$3" ] echo "" echo "\033[1;31musage: tl <interval (in seconds)> <duration (in hours)> <duration (in minutes)>" echo "" echo "\033[1;32mexample: tl 10 5 30" echo "(takes picture every 10 seconds next 5 hours , 30 minutes)" echo "\033[0m" elif [ ! -d /mnt/usb/tl_storage/pics_$(date +%f) ] sudo mkdir -p /mnt/usb/tl_storage/pics_$(date +%f) interval=$(($1 * 1000)) duration=$((($2 * 60 + $3) * 60000)) hour_act=$(date +%h) minute_act=$(date +%m) hour_tmp=$(($hour_act + $2)) minute_tmp=$(($minute_act + $3)) if [ "$hour_tmp" -gt 24 ] hour_then=$(($hour_tmp - 24)) else hour_then=$hour_tmp fi if [ "$minute_tmp" -gt 60 ] minute_then=$(($minute_tmp -60)) hour_then=$((hour_then + 1)) else minute_then=$minute_tmp fi echo "\033[1;31mtaking pictures timelapse in progress. check @ $hour_then:$minute_then" echo "\033[0m" cd /mnt/usb/tl_storage/pics_$(date +%f)/ sudo raspistill -o lapse_%04d.jpg -tl $interval -t $duration cd $home else interval=$(($1 * 1000)) duration=$((($2 * 60 + $3) * 60000)) hour_act=$(date +%h) minute_act=$(date +%m) hour_tmp=$(($hour_act + $2)) minute_tmp=$(($minute_act + $3)) if [ "$hour_tmp" -gt 24 ] hour_then=$(($hour_tmp - 24)) else hour_then=$hour_tmp fi if [ "$minute_tmp" -gt 60 ] minute_then=$(($minute_tmp -60)) hour_then=$((hour_then + 1)) else minute_then=$minute_tmp fi echo "\033[1;31mtaking pictures timelapse in progress. check @ $hour_then:$minute_then" echo "\033[0m" cd /mnt/usb/tl_storage/pics_$(date +%f)/ sudo raspistill -o lapse_%04d.jpg -tl $interval -t $duration cd $home fi
command:
tl 5 0 5 //every 5 sec 5 min
error:
/bin/tl: 19: /bin/tl: arithmetic expression: expecting eof: "09 + 0"
Comments
Post a Comment