#!/bin/sh
# $Id$
# *===========================================================================*
# |                 Copyright (c) 2008 Applaud Solutions UK Ltd               |
# |                             All rights reserved                           |
# *===========================================================================*

header_string="$Id$"
prog_version=`echo "$header_string" | awk '{print $3}'`
program=`basename $0 .sh`

usage="\t$program [username] [password]"

#
# Check the number of arguments
#
if [ $# -ne 2 ];
then
   printf "\n$program: this program requires two arguments.\n\n"
   printf "$usage\n\n"
   exit 0;
fi

sqlplus_un=$1
sqlplus_pw=$2

#
# Verify that the sqlplus executable is accessible
#

if test ! -x $XXAS_SQLPLUS ; then
   printf "\nERROR: Unable to execute "\$"ORACLE_HOME/bin/sqlplus. Please check your environment.\n\n"
   exit 1;
fi

#
# Verify that the given logon works
#
rslt=`$XXAS_SQLPLUS -s  <<STOP
${sqlplus_un}/${sqlplus_pw}
STOP
`
if test -n "$rslt" ; then
  printf "\nERROR: Unable to logon to sqlplus with the user $sqlplus_un:\n\n"
  printf "$rslt\n\n"
  exit 1;
fi

exit 0


