#!/bin/sh 
BASE=`dirname $0`
arguments=$@
PASSWORD=
HAS_CRS=
HOME=
for i in ${arguments}; do
    if [[ "$i" = -PASSWORD=*  ]]; then
           PASSWORD=`echo $i | sed 's/.[^=]*=//'`
	elif [[ "$i" = -HAS_CRS=*  ]]; then
           HAS_CRS=`echo $i | sed 's/.[^=]*=//'`
    elif [[ "$i" = -HOME=*  ]]; then
		   HOME=`echo $i | sed 's/.[^=]*=//'`
	fi
done

if [ "$HAS_CRS" = "true" ]; then	
	WHICH_SUDO=`$HOME/perl/bin/perl $BASE/VerifyCommand.pl sudo`
	`$WHICH_SUDO -k`
	WHOAMI=`echo $PASSWORD | $WHICH_SUDO -S -u root pwd &> /dev/null`
	RESULT=$?
	if [ $RESULT != 0 ]; then
   		echo "sudo permission for $i is not available for user on `hostname`"
   		exit 2;
	fi
fi


WHICH_EXPECT=`$HOME/perl/bin/perl $BASE/VerifyCommand.pl expect`
VERSION=`$WHICH_EXPECT -v`
RESULT=$?
if [ $RESULT != 0 ]; then
    echo "expect not available on `hostname`"
	exit 2;
fi
