[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Änderungen bei dyndns.org



Am Dienstag, den 28.05.2013, 15:26 +0200 schrieb Sascha Reißner:
> ..., hab ich mein Script etwas überarbeitet, ...
aber nicht angehängt.

Hier nun das Script:

#!/bin/bash

# source the configfile from ddclient for login and password
. /etc/ddclient.conf 2> /dev/null

if [ ${#login} -eq 0 ] ; then
	echo "no login set. aborted"
	exit 1
fi

if [ ${#password} -eq 0 ] ; then
	echo "no password set. aborted"
	exit 1
fi

cookies=`mktemp --tmpdir dyndns-cookie-XXXXXXXX`
login_page=`mktemp --tmpdir dyndns-login-XXXXXXXX`
account_page=`mktemp --tmpdir dyndns-account-XXXXXXXX`

# get the login-page
wget -q -O ${login_page} --save-cookies ${cookies} https://account.dyn.com/entrance/

# search the login-page for multiform-ID
found=0
multi=''
while read line; do
	if [ `egrep -c "<form id='login" <<< $line` -gt 0 ] ; then found=1; fi
	if [ `egrep -c "</form>" <<< $line` -gt 0 ]; then found=0; fi
	if [ `egrep -c "multiform" <<< $line` -gt 0 -a $found -eq 1 ]; then
		multi=`sed -e "s/.*value='\([[:alnum:]]*\)'.*/\1/" <<< $line`
	fi
done < ${login_page}

# login to dyndns
wget -q -O ${account_page} --load-cookies ${cookies} --post-data="username=${login}&password=${password}&multiform=${multi}" https://account.dyn.com/entrance/

# look if login was successfully
success=`grep -c -E "Welcome.*${login}" "${account_page}"`

if [ ${success} -eq 0 ] ; then
	echo "an error occurred while login at dynDNS. aborted"
	exit 1
fi

# logout from dyndns
wget -q -O /dev/null --load-cookies ${cookies} https://account.dyn.com/entrance/?__logout=1

# clean up temp-files
rm ${login_page}
rm ${account_page}
rm ${cookies}

echo "dynDNS login successfully"
exit 0

-- 
mfG Sascha

Gar freundliche Gesellschaft leistet uns ein ferner Freund, wenn 
wir ihn glücklich wissen.
		-- Johann Wolfgang von Goethe (Torquato Tasso IV)

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: