1

Whenever I try to run my shell script, I'm getting an error under 4 different if tests.

script.sh 45: script.sh: : Permission denied
script.sh 52: script.sh: : Permission denied
script.sh 59: script.sh: : Permission denied
script.sh 324: script.sh: : Permission denied

I did a chmod 777 on my script so everyone has permissions to it. The script is run like this:

./script fileToUse

Here is what those lines where it gave the error message looks like:

if ( "$VAR" == "Condition_1" )
then
    do stuff
elif ( "$VAR" == "Condition_2" )
then 
    do stuff
elif ( "$VAR" == "Condition_3" )
then 
    do stuff
else
    do stuff
fi

And the line of 324 looks like this:

if ( "$flagIsSet" -eq 0 )
then
    do stuff
fi

Any idea why I might be getting this error message and what it means?

4

1 に答える 1

6

括弧はサブシェルを実行します。比較には括弧を使用します。

if [ "$VAR1" = "Condition_1" ] ; then
    # do stuff
fi
于 2013-05-15T16:45:59.877 に答える