Skip to content

Instantly share code, notes, and snippets.

@ramblingenzyme
Last active August 23, 2016 02:45
Show Gist options
  • Save ramblingenzyme/b4c439211ffacb7703ed7c6634e475bb to your computer and use it in GitHub Desktop.
Save ramblingenzyme/b4c439211ffacb7703ed7c6634e475bb to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
TURNIN=false;
while getopts :c:a:u:th opt; do
case $opt in
c)
CLASS="$OPTARG"
;;
a)
ASSIGN="$OPTARG"
;;
u)
BANSHEEUSER="$OPTARG"
;;
t)
TURNIN=true;
;;
\?)
echo "Invalid option: -$OPTARG"
exit 1
;;
:)
echo "Option -$OPTARG requires an argument."
exit 1
;;
esac
done
shift $((OPTIND-1))
# Initialise ssh directive
DIRECTIVE="cd $CLASS/$ASSIGN &&"
# Copy the files
if [[ $# -ne 0 ]]; then
FILES=$@
elif [[ $# -eq 0 ]]; then
FILES=\*
fi
ssh $BANSHEEUSER@banshee.cs.uow.edu.au -t "mkdir $CLASS"
rsync -r $FILES $BANSHEEUSER@banshee.cs.uow.edu.au:$CLASS/$ASSIGN
# Create the submit directive
if [ "$TURNIN" = false ]; then
DIRECTIVE="$DIRECTIVE /share/bin/submit -u $BANSHEEUSER -c $CLASS -a $ASSIGN $FILES"
else
DIRECTIVE="$DIRECTIVE /share/bin/turnin -c $CLASS -a $ASSIGN $FILES && /share/bin/turnout -c $CLASS -a $ASSIGN"
fi
echo $DIRECTIVE
ssh $BANSHEEUSER@banshee.cs.uow.edu.au -t $DIRECTIVE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment