Facing problem in checking the directory existence

Hi All,

I have a written a scell script which checks the existence of a directory. The dierctory name is read from property file. Though the dierctory exists but it says - it does not exist--
Find my code below --

#! /bin/ksh
#Tibco Properties file is inclusion
. TibcoInstall.properties
function InstallDirCheck
{
echo "Checking for $2 Installation Directory Existence"
if [ -d $1 ]; then
echo "$2 Installation Directory Exists"
else
echo "$2 Installation Directory does not Exists"
fi
}
InstallDirCheck $1 $2

Thanks
Supriya

Put in quotes around.

if [ -d "$1" ]; then

I am not able to understand how is the script reading the directory name from the property file.

what are the params you are passing, the first param seems to be the dir that you are passing. Can you please give some more input and an example of what you are passing

#! /bin/ksh
#Tibco Properties file is inclusion
. TibcoInstall.properties

#Function To Check the TRA Installation Directory Existence
function InstallDirCheck
{
echo "Checking for $3 Installation Directory Existence"
if [ -d "$1" ]; then
echo "$3 Installation Directory Exists"
if [ -d "$2" ]; then
echo " $3 Script Base Directory Exists"
returnCheck="0"
else
echo " $3 Script Base Directory Does not Exist"
returnCheck="1"
fi
else
echo "$3 Installation Directory Does not Exist"
returnCheck="1"
fi
return $returnCheck
}
#Function To Check the BW Installation Directory Existence

function InstallFileCheck
{
echo "Checking for the TRA Installation Bin Files Existence"
# Check for FILE Existence
if [ ! -f $1 ]; then
echo "Installation List File $2 Does not Exists"
returnCheck="1"
else
echo "Installation List File $2 Exists"
let countValue=0
# Checking for each file existence in the List file
for i in $1
do
if [ ! -f $i ]; then
let countValue=countValue+1
fi
done
echo $countValue
if [ $countValue -gt 0 ]; then
echo "The required installables files listed in $2 are not Present"
returnCheck="1"
else
echo " The required $2 installables are Present"
returnCheck="0"
fi
fi
return $returnCheck
}

function InstallCall
{
#Installation Directory Existence Check
InstallDirCheck $1 $2 $5
let temp=$?
if [ $temp -eq "0" ]; then
#Installation Directory Existence Check
InstallFileCheck $3 $5
let temp1=$?
if [ $temp1 -eq "0" ]; then
ScriptCall $4 $5
exit 0
else
exit 1
fi
else
exit 1
fi
}
function ScriptCall
{
echo "Calling Installation Script $2"
./$base_script_dir/$1
}

function TibcoInstallCall
{
echo "TRA Installation Started"
InstallCall $base_install_dir_tra $base_script_dir_tra $tra_FileList $tra_script "TRA"
let temp= $?
if [ $temp -eq 0 ]; then
echo "TRA Installation Finished Successfully"
#BW Installation
echo "BW Installation Started"
InstallCall $base_install_dir_bw $base_script_dir_bw $bw_FileList $bw_script "BW"
let temp1=$?
if [ $temp1 -eq 0 ]; then
echo "BW Installation Finished Successfully"
#BC Installation
echo "BC installation Started"
InstallCall $base_install_dir_bc $base_script_dir_bc $bc_FileList $bc_script "BC"
echo "BC Installation Finished Successfully"
let temp2=$?
exit 0
else
exit 1
fi
else
exit 1
fi
}
echo "Installation of TIBCO Set Up starts"
echo "Enter your Input to continue"
echo " 1. Yes "
echo " 2. No "
read installInput
if [ "$installInput" = "2" ]; then
echo " Do You Want to Exit Installation wizard"
echo " Press 0.To Exit or 1. To Continue Installation"
read exCon
if [ "$exCon" = "0" ]; then
exit 0
else
TibcoInstallCall
fi
else
TibcoInstallCall
fi

-----Post Update-----

With quotes it did not work but when i hard code the directory name. it works fine.

Please let me know the solution for this.

Thanks
supriya

-----Post Update-----

#Domain and its Credentials
target_machine=nlvdhq498
target_user=sa_tibco_bc
target_install_script=/usr/admin/sysadm/home/sa_tibco_dva/B2B/BC/installUtilities.sh
Domain=dva
domain_user=admin
domain_pwd=admin
#Installation Base Dierctory
base_install_dir_tra=/distr/tibco/installations/baselayer/tra/
base_install_dir_bw=/distr/tibco/installations/baselayer/bw/
base_install_dir_bc=/distr/tibco/installations/baselayer/bc/
#Script File Base Directory
base_script_dir_tra=/distr/tibco/distribution/dva/baselayer/tra/
base_script_dir_bw=/distr/tibco/distribution/dva/baselayer/businessworks/
base_script_dir_bc=/distr/tibco/distribution/dva/baselayer/bc/
#TRA File List
tra_FileList=traFileList.txt
#BW File List
bw_FileList=bwFileList.txt
#BC File List
BC_FileList=bcFileList.txt
#TRA Script Name
tra_script=/distr/tibco/distribution/dva/baselayer/tra.sh
#BW Script Name
bw_script=/distr/tibco/distribution/dva/baselayer/bw.sh
#BC Script Name
BC_script=/distr/tibco/distribution/dva/baselayer/bc.sh

Got it sorted, get the parameters in a variable and then check for there existence due to some reason $1 is not working in test condition.
I did this way and it works.

#!/usr/bin/ksh
DIR=$2
function InstallDirCheck
{
echo "Checking for $2 Installation Directory Existence"
if [ -d $DIR ]; then
echo "$2 Installation Directory Exists"
else
echo "$2 Installation Directory does not Exists"
fi
}

InstallDirCheck $1 $2

It got solved, The problem was cntrlM characters.

Thanks
Supriya.