#!/bin/bash
#
# noodle_datamanager_report_get.sh
#
set -e
U=$1
P=$2
F=$3
R=$4
SITE="https://domain.tld"
COOKIE=noodle_cookie.tmp
if [ "$R" == "" ] ; then
echo NO >&2
exit 1
fi
if [ -f $COOKIE ] ; then
echo "already running"
exit 2;
fi
wget -q "$SITE/HandleLogin.po" --post-data="user_name=$U&user_password=$P" --keep-session-cookies --save-cookies $COOKIE -O /dev/null
wget -q "$SITE/datamanager/ReportView.po?folder=$F&reportHandle=$R&itemsPerPage=99" --load-cookies $COOKIE -O -
rm $COOKIE