notes/Image Trend CAD Dump ENFD GNfire BASH Shell-ntewBWxD.sh
#!/bin/bash
user=""
pass=""
loginurl="https://bridge.colliergov.net/default.cfm?page=login"
callurl="https://bridge.colliergov.net/resource/intranet/runform/cad_dispatch_List_ajax.cfm"
cookie="cookie"
if [ $# -eq 0 ];
then
unit="EN24"
else
unit=$1
fi
max="1000"
startdate="1/1/2016"
enddate="$(date +"%m/%d/%Y")"
#get data
echo "Retrieving login data..."
data="$(curl -s -c "$cookie" "$loginurl")"
securityToken="$(echo "$data"|grep -e securityToken |cut -d\" -f6)"
timeStampToken="$(echo "$data"|grep -e timeStampToken |cut -d\" -f6|cut -d\' -f2|sed 's/ /%20/g'|sed 's/:/%3A/g')"
echo "securityToken=$securityToken"
echo "timeStampToken=$timeStampToken"
#login and get cookie
echo "Logging into site..."
curl -c "$cookie" "$loginurl" --data "securityToken=$securityToken&timeStampToken=%7Bts%20%27${timeStampToken}%27%7D&UserID=$user&Password=$pass&t=0.101+seconds&spd=4542.1&submit=Submit" --compressed
#get and filter call info
echo "Retrieving Call Information..."
#curl -b cookie "$callurl?securityToken=$securityToken&timeStampToken=$timeStampToken&DateFrom=03%2F12%2F2016&DateTo=03%2F19%2F2016&sort=&sortOrder=DESC&start=1&jump=false&UnitNumber=EN24&cadStatus=ALL&nblock=250&RunTime=60&identifier=2/19/2016 7:48:11&runType=1&caller=&_="|html2text
curl -s -b cookie "$callurl?securityToken=$securityToken&timeStampToken=%7Bts%20%27${timeStampToken}%27%7D&DateFrom=$startdate&DateTo=$enddate&sort=&sortOrder=DESC&start=1&jump=false&UnitNumber=$unit&cadStatus=ALL&nblock=$max&RunTime=60&identifier=2/19/2016 7:48:11&runType=1&caller=&_="|\
#sed -e 's/<[^>]*>//g'|\
#html2text|\
grep -i -e "align" -e '</tr>'|\
sed 's|</TR>|~|gI'|\
cut -d\> -f2|cut -d\< -f1|\
tr '\n' '|'|\
sed 's/~/\n/g'|\
grep -v -e Enroute -e Records -e "Go to Page" -e "Unit Response Times" -e "Dest. Service"|\
sed '/|\n/d' |\
grep "nbsp"|sed -e 's/ |//g'|\
sed -e 's/ / /g'|sed 's/^..//'|sed 's/.$//'|\
tac
syntax highlighted by Code2HTML, v. 0.9.1