Rev 3318 | Blame | Last modification | View Log | RSS feed
#!/bin/bashif [ $# -lt 3 ]thenecho "Usage: $0 <from> <passwd> <email> [<email> ...]"exit 1fi# resolve links - $0 may be a softlinkPRG="$0"while [ -h "$PRG" ]; dols=`ls -ld "$PRG"`link=`expr "$ls" : '.*-> \(.*\)$'`if expr "$link" : '/.*' > /dev/null; thenPRG="$link"elsePRG=`dirname "$PRG"`/"$link"fidone# Get standard environment variablesPRGDIR=`dirname $(readlink -f "$PRG")`PYTHON_DIR=${PRGDIR}/../PyProj/src/shop2020/utilsDATE=`date +%Y-%b-%d`mysql -uroot -pshop2020 catalog -e " select i.id as ID, i.brand as Brand, i.model_number as 'Model Number', i.model_name as 'Model Name', i.color as Color, sum(c.availibility) as Availability from item i left join currentinventorysnapshot c on c.item_id = i.id where i.product_group = 'Handsets' and i.status =3 group by i.id having sum(c.availibility) >= 2 order by i.brand, i.model_number, i.color" > /tmp/items-deliverable-on-next-day.${DATE}.csvmysql -uroot -pshop2020 catalog -e " select i.id as ID, i.brand as Brand, i.model_number as 'Model Number', i.model_name as 'Model Name', i.color as Color, sum(c.availibility) as Availability from item i left join currentinventorysnapshot c on c.item_id = i.id where i.product_group = 'Handsets' and i.status =3 group by i.id having sum(c.availibility) < 2 order by i.brand, i.model_number, i.color" > /tmp/items-not-deliverable-on-next-day.${DATE}.csvmysql -uroot -pshop2020 catalog -e " select i.id as ID, i.brand as Brand, i.model_number as 'Model Number', i.model_name as 'Model Name', i.color as Color, sum(c.availibility) as Availability from item i left join currentinventorysnapshot c on c.item_id = i.id where i.product_group = 'Handsets' and i.status in (2,6) group by i.id order by i.brand, i.model_number, i.color" > /tmp/items-marked-out-of-stock.${DATE}.csv#Email the two report files.FROM=$1PASSWD=$2shift 2TO_LIST=""while (( "$#" ))doTO_LIST="${TO_LIST} -t $1"shiftdonepython ${PYTHON_DIR}/EmailAttachmentSender.py -f ${FROM} -p ${PASSWD} ${TO_LIST} -s "Item stock reports" -a /tmp/items-deliverable-on-next-day.${DATE}.csv -a /tmp/items-not-deliverable-on-next-day.${DATE}.csv -a /tmp/items-marked-out-of-stock.${DATE}.csvrm /tmp/items-deliverable-on-next-day.${DATE}.csv /tmp/items-not-deliverable-on-next-day.${DATE}.csv /tmp/items-marked-out-of-stock.${DATE}.csv