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..

DATE=`date +%Y\-%m\-%d`
DAY=`date +%d`
MONTH=`date +%m`
YEAR=`date +%Y`


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

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..

  • are you running the script via cron? – Danie Feb 15 '13 at 6:02

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


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

| improve this answer | |
  • Holy noodlemonster, you finished my workday after 10 hours. Thank you very much! – Harrys Kavan Feb 14 '13 at 18:02
  • 1
    Besides PATH, there are a number of other all-caps variables with special meanings. Using lowercase (or mixed-case) variable names is a good way to avoid problems like this. Also, storing commands in variables before running them can cause a variety of problems -- see BashFAQ #050. – Gordon Davisson Feb 15 '13 at 3:32

Generally it is considered good practice to use full paths in scripts to not depend on preset search paths.

  1. which wget will tell you the path to wget (probably /usr/bin/wget)
  2. you change COMMAND="wget --user...." to COMMAND="/usr/bin/wget --user...." (or wherever your wget sits)
| improve this answer | |

You probably want to do:


instead of


In order to preserve your current PATH variable but give the executables in /root/test/IA preference over other similarly named executables in the current PATH.

It is generally considered bad practice to use full paths to executables (i.e. to not use the PATH concept) in scripts, because this destroys the portability of the scripts and more importantly, it prevents you from overriding distribution default executables with your own. For example, most distros install wget in /usr/bin. If you want to install another version of wget in /usr/local/bin or in ~/.bin, without removing the distro default wget, but use your own wget in the script, then you should set PATH=$HOME/bin:/usr/local/bin:$PATH. This use of PATH is a critical feature if you do cross-platform development. In this situation you might have five different gcc toolchains installed. You don't want to have to have five different versions of a compilation script, so you rely on the shell's use of PATH to select the correct toolset.

Note that if you intend to run this script from crontab, you might have to explicitly add directories to the PATH variable because the default cron PATH includes just a few directories, as gregseth explains.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.