How to test directory availibility

Hello,

I'm trying to test if a directory specified in a script parameter is available or not.

I wrote a little code to do so, but there's a problem because I receive an error message.

My code:

#Verify command parameter
if [ ! test -d $1 ]
then
echo 'Incorrect command parameter'
echo 'You must specify an existing path name'
exit 2
fi

I hope someone can help me testing this availibility.... :confused:

Change your code to:

if [ ! -d $1 ]
then
echo 'Incorrect command parameter'
echo 'You must specify an existing path name'
exit 2
fi

Just an extension. Make sure $1 holds something.

if [ -z $1 ] ; then
echo "Enter a directory name"
exit 1
fi ;

if [ ! -d $1 ]
then
echo 'Incorrect command parameter'
echo 'You must specify an existing path name'
exit 2
fi

vino

Thank you very much.
This work perfectly. :smiley: :smiley: