Skip to content
Snippets Groups Projects
Commit 4b6689de authored by Nicolas M. Thiéry's avatar Nicolas M. Thiéry
Browse files

Added experimental script to compile and run programs in a docker sandbox

parent 54272f1f
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
usage () {
echo docker-compile-and-run [program.cpp]
echo
echo Compiles and executes a c++ program within a sandbox.
echo The standard input and output is passed down to the program.
echo The exit status is that of the compiler.
}
if [ -n $1 ]; then
usage
exit 0
fi
ID=`sudo docker run -d crosbymichael/build-essential sleep 1000`
sudo docker exec -i $ID sh -c "cat > prog.cpp" < $1
if sudo docker exec $ID g++ prog.cpp; then
sudo docker exec -i $ID ./a.out
else
exit $?
fi
sudo docker rm -f $ID > /dev/null 2>&1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment