Skip to content

Instantly share code, notes, and snippets.

@hkskoglund
Created November 7, 2017 13:49
Show Gist options
  • Save hkskoglund/9f0f4a6783661fcafaf24cfa6cf65120 to your computer and use it in GitHub Desktop.
Save hkskoglund/9f0f4a6783661fcafaf24cfa6cf65120 to your computer and use it in GitHub Desktop.
Motion detection to SD Card log D-link DCS-936L
#!/bin/bash
sdlog | grep -E 'Motion' | tail -n 150 | tac | nl
@hkskoglund
Copy link
Author

hkskoglund commented Nov 7, 2017

sdlog:

#!/bin/bash
curl 'http://192.168.0.110/eng/admin/export_log.cgi' -H 'Authorization: Basic <insert PWD here>' -H 'Referer: http://192.168.0.110/eng/web_log.cgi' --data 'export=true' -s

@hkskoglund
Copy link
Author

get latest video files from SD card:

[henning@satellite bin]$ cat getsleep2
#!/bin/bash
cd ~/Videoklipp/SLEEPLAB/
IPCAM=$2
FILES=$1
MODEL=$3
if [ -z "$1" ]; then
  FILES=100
fi
if [ -z "$2" ]; then
  IPCAM=192.168.0.110
fi
if [ -z "$3"]; then
   MODEL=DCS-936L
fi
echo "Fetching latest $FILES video files from $MODEL camera at $IPCAM"
curl "http://$IPCAM/eng/admin/export_log.cgi" -H 'Authorization: Basic <PASSWORD>' -H "Referer: http://$IPCAM/eng/web_log.cgi" --data 'export=true' -s | grep -E 'Motion'.*'SD Card is OK' | tail -n $FILES | cut -d' ' -f4 | { while read FILENAME ; do FILEPATH=$MODEL/${FILENAME:0:8}/${FILENAME:9:2}/$FILENAME;  curl -v -O -H 'Authorization: Basic <PASSWORD>' -H "Referer: http://$IPCAM/eng/admin/adv_sdcard.cgi" "http://$IPCAM/cgi/admin/getSDFile.cgi?file=$FILENAME&path=$FILEPATH" ; done }
cd -

@hkskoglund
Copy link
Author

Use -u admin: instead of Authorization header to hopefully get curl to login if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment