#!/bin/sh
# $Id: run 3151 2010-02-27 14:56:01Z eldering $

# Run wrapper-script called from 'testcase_run.sh'.
# See that script for more info.
#
# Usage: $0 <program> <testin> <output> <error> <exitfile>
#
# <program>   Executable of the program to be run.
# <testin>    File containing test-input.
# <output>    File where to write solution output.
# <error>     File where to write error messages.
# <exitfile>  File where to write solution exitcode.

PROGRAM="$1";   shift
TESTIN="$1";    shift
OUTPUT="$1";    shift
ERROR="$1";     shift
EXITFILE="$1";  shift

# Run the program while redirecting input, output and stderr
$PROGRAM <$TESTIN >$OUTPUT 2>$ERROR
exitcode=$?

printf "$exitcode" >$EXITFILE

exit $exitcode
