Skip to content

Instantly share code, notes, and snippets.

@figital
Created January 31, 2011 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save figital/804400 to your computer and use it in GitHub Desktop.
Save figital/804400 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script runs every minute using crontab. It logs into your router
# and grabs a DHCP that will be scraped later with PHP.
HOST='192.168.1.1'
FEEDDIR='/home/sfitchet/git-repos/roto'
COOKIES=$FEEDDIR'/cookies.txt'
USER='admin'
PASS='alpine' # j/k ;)
FILENAME='/DHCP_Static.asp' # This is URI we want from our router's admin page
# Get the DHCP HTML page and save it to a temporary location
wget -E -O $FEEDDIR$FILENAME'.html.temp' --cookies=on --keep-session-cookies --save-cookies=$COOKIES $HOST$FILENAME --http-user $USER --http-password $PASS
# When the download is complete, copy the file to the production path and then
# delete the temp file.
cp $FEEDDIR$FILENAME'.html.temp' $FEEDDIR$FILENAME'.html'
rm $FEEDDIR$FILENAME'.html.temp'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment