Jump to content

wp4.sh Error


Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...