Skip to content

Instantly share code, notes, and snippets.

@basham
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basham/57f22cdbf37aa3c8243e to your computer and use it in GitHub Desktop.
Save basham/57f22cdbf37aa3c8243e to your computer and use it in GitHub Desktop.
Static KRAD Sample App

Instructions

Start KRAD Sample App. Then run the following shell script.

bash static-krad-sampleapp.sh
#!/bin/sh
#
# http://www.gnu.org/software/wget/manual/wget.html
#
# -m --mirror
# -p --page-requisites (page dependencies)
# -k --convert-links (change references)
# -E --adjust-extension (add .html, etc)
# -O --output-document=file
# -P --directory-prefix=prefix
# -a --append-output=logfile
# -o --output-file=logfile (overwrite log)
# Download the login page.
#wget -O login.html http://localhost:8080/krad-dev/
wget --save-cookies cookies.txt --keep-session-cookies -O login.html http://localhost:8080/krad-dev/
# Extract the hidden form data and transform them into URL parameters.
hiddenData=`grep value < login.html | grep -v script | grep -v login_user | tr '=' ' ' | awk '{print $5"="$7}' | sed s/\"//g | tr '\n' '&'`
# Remove the login page.
rm login.html
# Add the login credentials.
postData=login_user=admin'&'${hiddenData}
# Send the post data, login, and mirror the site.
wget --load-cookies cookies.txt --save-cookies cookies.txt --keep-session-cookies -m -p -k -E --post-data ${postData} http://localhost:8080/krad-dev/kr-login/login
echo $postData
@basham
Copy link
Author

basham commented Sep 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment