From 72e3427ea9b10585b54a80ed58318f46224c52d0 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Tue, 3 Nov 2015 13:47:44 +0100 Subject: [PATCH] Tested version running with simple (singular) test case --- run.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 run.sh diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..e1e370d --- /dev/null +++ b/run.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +echo 'Loggin in' +curl -b cookies -c cookies -s -F 'email=ChristianLupus@web.de' -F 'form_id=packt_user_login_form' -F 'password=naitsirhc' -F 'op=Login' https://www.packtpub.com/ > /dev/null + +echo 'Obtaining free book information' +url=$(curl -b cookies -c cookies -s https://www.packtpub.com/packt/offers/free-learning | grep freelearning-claim free.html | grep -o 'href="[^"]*' | grep -o '/free.*') + +echo 'Claiming free book' +#curl -b cookies -c cookies https://www.packtpub.com$url + +echo 'Downloading books' +id=$(echo $url | grep -o '/[0-9/]*/' | grep -o '[0-9]*') +#curl -b cookies -c cookies -J -O https://www.packtpub.com/ebook_download/$id/pdf +#curl -b cookies -c cookies -J -O https://www.packtpub.com/ebook_download/$id/epub +out=$(curl -b cookies -c cookies -J -O -O https://www.packtpub.com/ebook_download/$id/pdf https://www.packtpub.com/ebook_download/$id/epub 2>&1 ) + +ret=$? + +echo 'Logging off' +curl -b cookies -c cookies -s https://www.packtpub.com/logout > /dev/null + +if [ $ret -ne 0 ]; then + + if [ $ret -eq 23 ]; then + echo Could not write file to file system: + fi + + echo -e "$out" + +fi