#!/bin/sh #set -x #echo 'Logging in' formid=$(curl -b cookies -c cookies -s https://www.packtpub.com/ | grep 'form_build_id' | head -n 1 | grep -Eo 'value="[^"]*"' | sed -E 's@value="(.*)"@\1@') curl -b cookies -c cookies -s -F 'email=ChristianLupus@web.de' -F 'form_id=packt_user_login_form' -F 'password=naitsirhc' -F 'op=Login' -F "form_build_id=$formid" https://www.packtpub.com/ > /dev/null #echo 'Obtaining free book information' title=$(curl -b cookies -c cookies -s https://www.packtpub.com/packt/offers/free-learning | awk '/

/,/<\/h2>/' | tr -d '\n\r\t' | grep -Po '

.*?

' | head -n 1 | sed 's@

\(.*\)

@\1@') echo "The packt book today is \"$title\". You can find it under https://www.packtpub.com/packt/offers/free-learning."