#!/bin/bash

CAMPDIR=/home/staff/meidanis/aulas/mc600/PROLOG/campdir
PUBDIR=/home/staff/meidanis/public_html/courses/mc600/200002/PrologCamp

rcamp=rcamp$1.txt
final=final$1.txt
echo $rcamp

pushd $CAMPDIR
ls -1t *.prolog | sed 's/.prolog//' | gawk 'BEGIN{print "jogadores([zuba"}{print ",", $0}END{print "])."}' > $PUBDIR/jogadores.prolog
echo "Campeonato iniciado: " > $PUBDIR/$rcamp
date >> $PUBDIR/$rcamp
pl -f $PUBDIR/lp.prolog -A 1000 > $PUBDIR/tmprcamp
tail -1 $PUBDIR/tmprcamp >> $PUBDIR/$rcamp
echo >> $PUBDIR/$rcamp
cat $PUBDIR/tmprcamp >> $PUBDIR/$rcamp
date > $PUBDIR/$final
popd
pushd $PUBDIR
echo "" | ./faztab.pl > $PUBDIR/tabela.html
echo "" | ./notasP.pl > $PUBDIR/notas.html
popd
