Debian – error while executing bash script -> command not found

bashdebianwget

i made this script here, and get the error

IA-exporto.sh: 13: wget: not found

i tried changing the " by ` and mixed all together and rearranged, but it just won't do..

#!/bin/bash
UNAME="maximilian"
PWD="password"
DATE=`date +%Y\-%m\-%d`
DAY=`date +%d`
MONTH=`date +%m`
YEAR=`date +%Y`

PATH="/root/test/IA"

URL="http://www.my-corpo.com/_backend/index.php?date=$YEAR-$MONTH-$DAY&view=csv"
COMMAND="wget --user=$UNAME --password=$PWD $URL -O $PATH-$DATE.csv"
$COMMAND

i even tryed to set before and after every variable a ", so it looks like

COMMAND="wget --user="$UNAME" --password="$PWD" "$URL" -O "$PATH"-"$DATE".csv"

but when i echo $COMMAND it looks very right, in fact, when i copy it from and insert it, it works..

Best Answer

You're overriding the $PATH variable, which determines which directories are searched for executables (like wget):

PATH="/root/test/IA"

So the shell is only looking in /root/test/IA for the wget command. Change your variable name to something else.