santuna
September 30, 2005, 5:03am
1
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....
Change your code to:
if [ ! -d $1 ]
then
echo 'Incorrect command parameter'
echo 'You must specify an existing path name'
exit 2
fi
vino
September 30, 2005, 7:51am
3
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
santuna
September 30, 2005, 8:40am
4
Thank you very much.
This work perfectly.