Upgrading firmware wifiShield: Arduino Path not setted...

Hello

I've spent a lot of time trying to updrade the firmware on my wifishield but I cant't figure it out.

Following the instructions on https://www.arduino.cc/en/Hacking/WiFiShieldFirmwareUpgrading , I get stuck at the command

sudo ./ArduinoWifiShield_upgrade.sh -f all

The terminal returns "Arduino Path not setted. Retry...".

However I've changed the paths in the file ArduinoWifiShield_upgrade. sh
from

WIFI_FW_PATH="/hardware/arduino/avr/firmwares/wifishield/binary" and AVR_TOOLS_PATH="/hardware/tools/avr/bin"

to

WIFI_FW_PATH="~/arduino-1.6.5-r5/hardware/arduino/avr/firmwares/wifishield/binary" and
AVR_TOOLS_PATH="~/arduino-1.6.5-r5/hardware/tools/avr/bin"

because these are I guess the paths I have to change in the file (?). (Arduino-1.6.5-r5 is installed in my home folder.)

Trying to set one of the the paths using the command

usr@ubuntu15.04:~/arduino-1.6.5-r5/hardware/arduino/avr/firmwares/wifishield/scripts$ sudo ./ArduinoWifiShield_upgrade.sh -a WIFI_FW_PATH="~/arduino-1.6.5-r5/hardware/arduino/avr/firmwares/wifishield/binary"

returns from my terminal:

./ArduinoWifiShield_upgrade.sh: 79: cd: can't cd to WIFI_FW_PATH=~/arduino-1.6.5-r5/hardware/arduino/avr/firmwares/wifishield/binary/home/beuk/arduino-1.6.5-r5/hardware/tools/avr/bin
./ArduinoWifiShield_upgrade.sh: 80: ./ArduinoWifiShield_upgrade.sh: ./avr-objcopy: not found
./ArduinoWifiShield_upgrade.sh: 81: ./ArduinoWifiShield_upgrade.sh: ./avr-objcopy: not found

Command sudo ./ArduinoWifiShield_upgrade.sh -a with argument
~/arduino-1.6.5-r5/hardware/arduino/avr/firmwares/wifishield/binary
returns the same.

Has anyone a hint to solve this problem? (Im on ubuntu15.04, wifishield = "SHIELD WIFI INTEGRATED ANTENNA)

fagus

Check your file and directory permissions.

all the files used are executable:
~/arduino-1.6.5-r5/hardware/arduino/avr/firmwares/wifishield/scripts/ArduinoWifiShield_upgrade.sh
~/arduino-1.6.5-r5/hardware//tools/avr/bin
~/arduino-1.6.5-r5/hardware/arduino/avr/firmwares/wifishield/wifi_dnld/Release/wifi_dnld.elf