notes/Target Solutions SOG reader-MZJFjBZZ.sh
#!/bin/bash
site="http://app.targetsolutions.com"
dash="$site/tsapp/dashboard/pl_fb"
customerid="24704"
customerpath="gnfire"
cookie="cookie"
curl="curl -b "$cookie" -s"
user="$1"
pass="$2"
echo "Logging in..."
curl -c "$cookie" "$site/auth/?action=login.processlogin&customerid=24704&customerpath=gnfire" -d "username=$user&password=$pass"
#curl -b "$cookie" -s "$site/auth/index.cfm?action=login.login&customerid=$customerid&customerpath=$customerpath"
curl -b "$cookie" "$site/template_self_reg/newlogin.cfm?ld=SjssMl9GRlVHRSpdP0haOFM9KzBLT0hNJF0sKT02TEM1UEBPLzlMIVFJKD5LJyw7MiU6OzI9OSQwCg=="
#chuck curl -b "$cookie" "$site/template_self_reg/newlogin.cfm?ld=SjssMl9GRlVHRSpdP0haOFM9KzBLT0hNJF0sKTc2TFM3UDBPLzlMIVFJKD5LJyw7MiU6OzE_OTQwCg=="
curl -b "$cookie" -s "http://app.targetsolutions.com/tsapp/dashboard/pl_fb/index.cfm?fuseaction=c_pro_documents.showFile&doc=1330533" -o "1.pdf"
#homescreen curl -b "$cookie" "http://app.targetsolutions.com/tsapp/dashboard/pl_fb/index.cfm?fuseaction=c_pro.showHome"
echo -e "Retrieving SOGs..."
curl -b "$cookie" -s "$dash/index.cfm?fuseaction=c_pro.getSchedule&_=1460419698350"|\
grep "SOG"|\
while read line
do
link="$(echo "$line"|cut -d\" -f2|sed 's/amp;//g')"
data="$($curl "$dash/$link")"
pdf="$(echo "$data"|grep "documents.showFile"|cut -d\" -f2|sed 's/amp;//g')"
userid="$(echo "$data"|grep UserID|cut -d\" -f8)"
transcriptID="$(echo "$data"|grep transcriptID|cut -d\" -f6)"
courseid="$(echo "$data"|grep courseid|cut -d\" -f8)"
duration="$(echo "$data"|grep "durationpd"|cut -d\> -f2|cut -d\< -f1)"
date="$(date +%m/%d/%Y)"
hour="$(date +%I)"
AMPM="$(date +%p)"
$curl "$dash/index.cfm?fuseaction=c_pro_custom_activities.completeModifyUserCustomActivity&returnPath=home" --data "jscrollpanefocus=&UserID=$userid&attachmentID=¤tVersionNumber=1&transcriptID=$transcriptID&courseid=$courseid&customerid=$customerid&status=0&selfAssigned=false&saa=false&nodeUserVal1=$date&nodeUserVal1_endTimeHour=$hour&nodeUserVal1_endTimeMin=45&nodeUserVal1_endTimeAMPM=$AMPM&nodeUserVal1_endTime=$hour%3A45+$AMPM&nodeUserVal1_timeZone=4&nodeUserVal2_viewed=true&nodeUserVal2=1&duration=$duration&completedate=$date $hour%3A45+$AMPM+EST"
if [[ ! -z $pdf ]]
then
echo "Retrieving PDF..."
#echo "$dash/$pdf"
data="$($curl "$dash/$pdf")"
pdf="$(echo "$data" |grep "tsresources.targetsolutions.com"|grep "link"|cut -d\" -f4)"
curl -s "$pdf" -o 1.pdf
xpdf 1.pdf
fi
done
syntax highlighted by Code2HTML, v. 0.9.1