#!/bin/sh
#
# This script gets email and returns user belongs to the email.
#

test -n "$COMMON_LIB_PATH" || COMMON_LIB_PATH="`dirname $0`"
. "${COMMON_LIB_PATH}/common.sh"

while true
do
	read email
	if [ $? != 0 ]; then
		break;
	elif [ "$email" != "$END_OF_INPUT" ]; then
		user_account="`awk -F: -vemail=$email -vdomain=$DOMAIN -f ${PARSE_EMAIL_AWK} $USER_ACCOUNTS`"

		if [ -n "$user_account" ]; then
			send_line "$user_account"
		fi
		send_end
	fi
done

