It's been a long week and my brain is clearly not functioning right so hopefully someone can help me out here.
I've got a function in a script which just checks if a MySQL database directory exists or not. Code is as follows:
dbCheck2() {
if [ -d '/var/lib/mysql/$IPdb' ];
then {
:
# carry on in parent script
}
else {
echo "No Valid Database specified. Please try again."
some_other_function
}
fi
}
For arguments sake let the variable IPdb = test as this value is coming from another function. Now even when the directory /var/lib/mysql/test exists it still displays the else statement.
Can someone put me out of my misery and tell me what's wrong?
i am new to unix world so i am not sure my advice will be useful or work... i am just studyind test command now....
try:
dbCheck2()
{if
[ -d /var/lib/mysql/$IPdb ]
echo hi #just to check if it goes through first if
then :
# carry on in parent script
else
echo "No Valid Database specified. Please try again."
some_other_function
fi
}