#!/bin/bash [ -x /etc/icpc/bocaserver.sh ] && . /etc/icpc/bocaserver.sh if [ "$BOCASERVER" != "" ]; then if [ "$BOCASERVERS" == "" ]; then BOCASERVERS=$BOCASERVER else BOCASERVERS="$BOCASERVERS;$BOCASERVER" fi fi if [ "$BOCASERVERS" == "" ]; then echo "This computer has no configured BOCA server. Ask an admin to update /etc/icpc/bocaserver.sh (usually resetting everything is an easy way)" exit 1 fi for i in uuencode wget tr perl sha256sum cut; do p=`which $i` if [ -x "$p" ]; then echo -n "" else echo "$i" not found exit 1 fi done temp=/tmp/.temp.`date +%s%N`.txt if [ "$1" == "" ]; then echo "Usage: $0 USER PASSWORD PROBLEM LANGUAGE FILE" echo "" echo "where USER is your username" echo "PASSWORD is your password" echo "FILE is your submission file" echo "PROBLEM and LANGUAGE are according to defined in BOCA" echo "==>>You can check at your BOCA interface to be sure<<==" echo "PROBLEM is usually a single letter e.g. A or B or C etc" echo "LANGUAGE is usually one of { c cpp cc java }" echo "==>>You can check at your BOCA interface to be sure<<==" exit 1 fi runaux=`which boca-submit-run-aux` if [ "$runaux" == "" ]; then runaux=/usr/bin/boca-submit-run-aux fi runroot=`which boca-submit-run-root-wrapper` if [ "$runroot" == "" ]; then runroot=/usr/bin/boca-submit-run-root-wrapper fi if [ -r "$5" ]; then nom=`echo -n "$5" | perl -MURI::Escape -lne 'print uri_escape($_)'` for BOCASERVER in `echo $BOCASERVERS | tr ';' ' '`; do echo "BOCASERVER=$BOCASERVER" > $temp echo "user=$1" >> $temp echo "pass=$2" >> $temp echo "problem=$3" >> $temp echo "language=$4" >> $temp echo "name=`basename $5`" >> $temp uniq=`sha256sum "$5" | cut -f1 -d' '` echo "uniq=$uniq" >> $temp echo -en "data=\"" >> $temp uuencode -m zzzzzzzzzz < "$5" | grep -v "begin-base64.*zzzzzzzzzz" >> $temp echo -e "\"" >> $temp $runaux $temp if [ "$?" == "2" ]; then echo "$BOCASERVER: time-out - this will automatically retry soon, you should not worry" $runroot "$BOCASERVER" "$1" "$2" "$3" "$4" "`basename $5`" "$5" fi [ -f "$temp" ] && rm -f $temp done else echo "file $1 not found/readable" fi