globalvariable Posted January 1, 2013 Share Posted January 1, 2013 After using wget to retrieve the wp4.sh file for the wifi pineapple (Mark IV) after pressing enter for the pineapple netmask I get an error which is the following: wp4.sh: 14: wp4.sh: [[: not found The first few lines of the code for the script are: #!/bin/bash #define variables echo "$(tput setaf 1) _ ___ _______ ____ _ __ " echo " | | / (_) ____(_) / __ \\(_)___ ___ ____ _____ ____ / /__ " echo " | | /| / / / /_ / / / /_/ / / __ \/ _ \/ __ '/ __ \/ __ \/ / _ \\" echo " | |/ |/ / / __/ / / / ____/ / / / / __/ /_/ / /_/ / /_/ / / __/" echo " |__/|__/_/_/ /_/ /_/ /_/_/ /_/\___/\__,_/ .___/ .___/_/\___/ " echo " $(tput sgr0) OWN the Network $(tput setaf 1)/_/ /_/$(tput sgr0) v2.1" echo "" echo -n "Pineapple Netmask [255.255.255.0]: " read pineapplenetmask if [[ $pineapplenetmask == '' ]]; then pineapplenetmask=255.255.255.0 #Default netmask for /24 network fi Quote Link to comment Share on other sites More sharing options...
barry99705 Posted January 1, 2013 Share Posted January 1, 2013 (edited) What OS are you running the script on? Edited January 1, 2013 by barry99705 Quote Link to comment Share on other sites More sharing options...
globalvariable Posted January 1, 2013 Author Share Posted January 1, 2013 So far I have tried it in Linux Backbox 3.0, Ubuntu 12.04 LTS, and Linux Mint 14. All have returned the same error. Quote Link to comment Share on other sites More sharing options...
barry99705 Posted January 1, 2013 Share Posted January 1, 2013 (edited) Weird. I just downloaded it to my ubuntu box and it worked just fine. Are you starting it as root? Edited January 1, 2013 by barry99705 Quote Link to comment Share on other sites More sharing options...
globalvariable Posted January 1, 2013 Author Share Posted January 1, 2013 Yes, I am starting it as root. I am using sudo sh wp4.sh. My friend doesn't have the problem either. This is pretty weird. Quote Link to comment Share on other sites More sharing options...
barry99705 Posted January 1, 2013 Share Posted January 1, 2013 try sudo ./wp4.sh That's how I run it. Quote Link to comment Share on other sites More sharing options...
globalvariable Posted January 1, 2013 Author Share Posted January 1, 2013 Regardless of the way I run it, it still comes up with the same error. Quote Link to comment Share on other sites More sharing options...
digininja Posted January 1, 2013 Share Posted January 1, 2013 Try typing in the default value rather than just hitting enter. I think the bug is that this if [[ $pineapplenetmask == '' ]]; then[/CODE]should be[CODE]if [[ "$pineapplenetmask" == '' ]]; then[/CODE]Same for the other variables.I'll talk to Seb about fixing it up. Quote Link to comment Share on other sites More sharing options...
barry99705 Posted January 2, 2013 Share Posted January 2, 2013 Try typing in the default value rather than just hitting enter. I think the bug is that this if [[ $pineapplenetmask == '' ]]; then[/CODE]should be[CODE]if [[ "$pineapplenetmask" == '' ]]; then[/CODE]Same for the other variables.I'll talk to Seb about fixing it up.Why does it just work when I run it though? Quote Link to comment Share on other sites More sharing options...
Mr-Protocol Posted January 2, 2013 Share Posted January 2, 2013 Mine works as is. I might be the default terminal that is causing the issue? Quote Link to comment Share on other sites More sharing options...
digininja Posted January 2, 2013 Share Posted January 2, 2013 I don't know what distro Backbox is based on but the other two are Ubuntu based so maybe there is something there. Could be that a different shell has been installed and has mapped itself over bash. Either way I'm surprised this works on any platform as it shouldn't as far as I know. I've told Darren and Seb and we will get it fixed up on the server soon. The reason it fails, as I forgot to mention earlier, is that when $pineapplenetmask isn't defined, which it won't be if you just hit enter, the evaluation becomes if [[ == '' ]]; then[/CODE]which is syntactically incorrect. The variable has to be wrapped in double quotes so it can be[CODE]if [[ "" == '' ]]; then[/CODE]which is then correct.It has to be double quotes as single quotes do not expand variables inside of them so you would end up with the literal conditional check.[CODE]if [[ '$pineapplenetmask' == '' ]]; then[/CODE] Quote Link to comment Share on other sites More sharing options...
Sebkinne Posted January 3, 2013 Share Posted January 3, 2013 Something important to note: This script has to be executed with bash! If it is executed with sh (sh wp4.sh) it will not work right and throw those [[ errors at you. To properly execute wp4.sh use the following commands: /bin/bash wp4.sh[/CODE]or[CODE]chmod +x wp4.sh./wp4.sh[/CODE]These are the correct ways to run this script.Digininja is right though, those double quotes are important for older versions of bash, the current releases of bash are all able to recognize the empty variable and treat it accordingly.We will get the script updated asap though! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.