Created
July 6, 2014 04:41
-
-
Save mohamedelhabib/31eaacf9d3106fd9a1ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| ####################### PRESTASHOP PARAM ####################### | |
| urladminsite=http://prestashop.domain.com/adminxxx/ # prestashop admin url | |
| [email protected] # admin login | |
| passwd=password # admin password | |
| adminController=AdminPdf # the controller to call after login | |
| adminControllerParam='&submitAction=generateInvoicePDF&id_order=250' | |
| cookieFilePath=/tmp/cookie.txt # path of the cookie file that will be created | |
| ####################### IDENTIFICATION ####################### | |
| # login and get cookie | |
| rm /tmp/login.php | |
| rm $cookieFilePath | |
| wget -q --save-cookies=$cookieFilePath --post-data='ajax=1&token=&redirect='$adminController'&controller=AdminLogin&submitLogin=1&passwd='$passwd'&email='$email --keep-session-cookies -O /tmp/login.php $urladminsite'ajax-tab.php' | |
| if [ -n "$(grep 'errors' /tmp/login.php)" ] | |
| then | |
| error=$(grep 'errors' /tmp/login.php | sed 's/.*\["\(.*\)"\].*/\1/g') | |
| echo 'Login KO : '$error | |
| exit | |
| else | |
| echo 'Login OK ...' | |
| token=$(grep 'redirect' /tmp/login.php | sed 's/.*token=\(.*\)".*/\1/g') | |
| echo 'TOKEN : '$token # print token | |
| if [ -z "$(echo $token | grep ^[a-z0-9]*)" ] | |
| then | |
| echo 'ERROR : no token' | |
| exit | |
| fi | |
| fi | |
| ####################### Do action after login ####################### | |
| wget -q -O result.pdf --load-cookies=$cookieFilePath --keep-session-cookies $urladminsite'index.php?token='$token'&controller='$adminController$adminControllerParam |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment