#!/bin/bash
SERVER_ADDR=$1
FILE_TO_GET=$2

#echo "Fetching $FILE_TO_GET from $SERVER_ADDR"

read OUTPUT < <(sudo tftp $SERVER_ADDR <<< "get $FILE_TO_GET")

if [ "${OUTPUT/*Received*/received}" = "received" -o -z "${OUTPUT/*>}" ]; then
	exit 0
fi

[ -f $FILE_TO_GET ] && unlink $FILE_TO_GET
exit 1
#echo "Done"
