#!/usr/bin/ensim-python
#
# Copyright (c) Ensim Corporation 2000, 2001   All Rights Reserved.
#
# This software is furnished under a license and may be used and copied
# only  in  accordance  with  the  terms  of such  license and with the
# inclusion of the above copyright notice. This software or any other
# copies thereof may not be provided or otherwise made available to any
# other person. No title to and ownership of the software is hereby
# transferred.
#
# The information in this software is subject to change without notice
# and  should  not be  construed  as  a commitment by Ensim Corporation.
# Ensim assumes no responsibility for the use or  reliability  of its
# software on equipment which is not supplied by Ensim.
#
#
# This function returns 1/0 if a domain exists/doesn't exist on a WEBppliance
#
# Usage:
#
# DomainExists
#
# Example:
#
# DomainExists domain.com

import getopt
import sys
from vh3 import virthost

if (len(sys.argv) != 2) or (sys.argv[1] == "--help"):
    print "usage: DomainExists <domainname>";
else:
    options, args = getopt.getopt(sys.argv[1:],"")
    for domain in args:
        siteindex = virthost.get_site_from_anything(domain)
        if not siteindex:
            print "0"
        else:
            print "1"

