Need small sh tips

interfasys

Verified User
Joined
Oct 31, 2003
Messages
2,100
Location
Switzerland
I don't know shell scripting, but I'm trying to finish the Urchin Howto.

This:
Code:
#!/bin/sh

URCHINPATH="/usr/local/urchin"
GETPARAM=`$URCHINPATH/util/uconf-driver action=get_parameter table=user name="$username" parameter=cs_rlist`
echo $GETPARAM

can return:
-1

Now I'm trying to detect the case where it's -1 in order to call an alternate script.

Whatever I try, -1 is never detected...
Things like :
Code:
if ["$GETPARAM" == "-1"]
then
etc.

If you have the solution, it would be appreciated.
 
Perhaps if you could post more lines of your code, then we could help. The above code should work. What kind of error messages are you getting? Which OS is this?
 
It's on FreeBSD

I tried this :

# cd /usr/local/directadmin/scripts/custom
# edit domain_create_post.sh

Pasted this

#!/bin/sh

PARFUM=-1
if [$PARFUM -eq "-1"]
then echo "-1 detected"
else echo "detection failed"
fi

And I always get "detection failed".
 
You need to put a space after '[' and another space before ']':

if [ $PARFUM -eq "-1" ]
 
Last edited:
Back
Top