PDA

View Full Version : why is this bash conditional statement wrong?



akimatsu123
July 30th, 2009, 12:00 PM
if [[ ("$bool_cracked" != "y") || ("$bool_cracked" != "Y") ]]
then
echo "Will restart aircrack-ng. Press any key to continue (Ctrl+C to quit)..."
else
fi

the above is a script from my wifi cracking script. yes, i know, only perform it on your own wifi blablabla. i'm just doing this for learning purposes, and since it seemed fun to write a aircrack0ng script, that's what im doing.

the above statement throws out the error "syntax error near unexpected token `fi'" what's wrong with my script? thanks

wojox
July 30th, 2009, 12:05 PM
There is nothing between the else and fi. Your telling it If this then do this Else (then there is nothing there to do).

Majorix
July 30th, 2009, 12:25 PM
Just remove the "else". You won't need it unless you want to do something if the condition is not met.

hyperAura
July 30th, 2009, 05:32 PM
so in bash scripting language fi is like saying the if conditional statement is finished??

wojox
July 30th, 2009, 06:11 PM
Yes kind of weird huh?

hyperAura
July 31st, 2009, 08:39 PM
well yeah it looks quite weird to me as ive never seen a programming language using something to denote the end of a conditional statement..:)