ddclient seems to be updating IP, but reporting errors

DynDns now requires you to log in to your account from the web at least once a month, otherwise your free account will expire. Make a cron job for this script to automate this requirement.

Code:
#!/bin/sh

# This script requires ftp/wget and security/ca_root_nss.

# Login to DynDns to keep an account active.
# You have to add an entry like below to ~/.netrc.
# machine account.dyn.com    login <username> password <pasword>

## Fill this in with the same value as <username> above. ####
USERNAME="m020543"
#############################################################

PROGNAME=dyndns_login
CERTFILE=/usr/local/share/certs/ca-root-nss.crt
COOKIE=`/usr/bin/mktemp /tmp/${PROGNAME}_cookie.XXXXXX`
OUTPUT=`/usr/bin/mktemp /tmp/${PROGNAME}_output.XXXXXX`
USERAGENT="Mozilla/5.0 (X11; FreeBSD amd64; rv:23.0) Gecko/20100101 Firefox/23.0"

MULTIFORM=`/usr/local/bin/wget --save-cookies "$COOKIE" --ca-certificate="$CERTFILE" -U "$USERAGENT" -O - -q https://account.dyn.com | /usr/bin/awk -F\' '/multiform/{ print $6 }'`
/usr/local/bin/wget --load-cookies "$COOKIE" --ca-certificate="$CERTFILE" -U "$USERAGENT" -O "$OUTPUT" -q --post-data="iov_id=&submit=Log+in&multiform=$MULTIFORM" https://account.dyn.com

if /usr/bin/grep -E "(Welcome|Hi).*$USERNAME" $OUTPUT > /dev/null 2>&1; then
    echo DynDns login successful.
else
    echo DynDns login failed.
    FAILED="true"
fi

rm $COOKIE
rm $OUTPUT
 
if [ "$FAILED" = "true" ]; then
    exit 1
fi
 
I tested the wrong version before I posted. I had it working when I put the username and password in the URL, but the one above doesn't seem to be reading from ~/.netrc and adding the credentials to the post. Also, I went with ftp/wget instead of ftp/curl because curl was sometimes not writing to the cookie file when grabbing the multiform field.

So in the meantime, it will work if you add username=$USERNAME&password=$PASSWORD to the post data, but that sucks.
 
I had success with ~/.netrc but you must be careful with the fields. Something like this:

Code:
machine members.dyndns.org    login dvl password foobar

HTH.
 
You had success with the script I just posted? My /root/.netrc looks like this.

Code:
machine members.dyndns.org login me password foo
machine account.dyn.com    login me password foo

As soon as I take out username=$USERNAME&password=$PASSWORD from post-data it fails.
 
I have not used your script but I had success with another. Check the man pages for the argument for reading the file. It is not automatic.
 
I've had success reading from ~/.netrc with curl as well, but not with wget. I'm forced to use wget because of the problem writing to the cookie file I described above.
 
Back
Top