Can't seem to get this script to run, I have user access to the data I'm trying to download but it just won't run. If anyone can help with wget scripts it would be appreciated.

for i in $(seq 1 9); do wget -q --http-user="xxxxxx" --http-passwd="xxxxxx" http://cdaac-www.cosmic.ucar.edu/cdaac/rest/tarservice/data/cosmic2015/atmPrf/2015.00$i -O cosmic_atmPrf_2015.00$i.tar; done
  • are you sure you have the right permission ? error 126 occurs when there is a Permission problem or command is not an executable. – Sufiyan Ghori May 26 '16 at 2:24

As Sufiyan Ghori stated, the error you are getting indicates you are trying to execute something that you don't have permissions to execute.

Here are a few things to look at and try:

  • See which wget you are using and check permissions (use the result from the first command as argument to the second if the argument is a path)

    type wget
    ls -l /path/to/wget

    you should get something like this:

    $ type wget
    $ ls -l /usr/bin/wget
    -rwxr-xr-x 1 root root 439944 May 4 17:07 /usr/bin/wget

    If the last x in -rwxr-xr-x is not present, it means you do not have permission to run that program. See if there is a different location with wget on the system by running locate bin/wget; as root run chmod a+x /path/to/wget.

  • If the type wget command returns something else, starting with:

    wget is a function ...

    wget is aliased to 'e1(){ return 126;};e1;'

    Then the alias or function may be the issue. use unalias wget or unset wget to clear them, or just update your script to use the full path to wget (which wget should give you the path to the wget executable).

  • If you don't have permissions to fix the issue, you could substitute a curl command for the wget - it will function the same, the arguments are just different.

  • One last thing to look at. On the terminal, type the following to get bash to echo back out verbose info.

    set -x

    In your command, change the -q to a -S -v -d to get detailed information from wget. Run the command and review the output - there may be a clue there.

    Use set +x to turn off the bashing command echoing


  • Regarding your comment: There needs to be a space in that command:

    ls -l /usr/bin/wget

  • What happens if you type /usr/bin/wget ? Also try typing curl without any arguments (it won't do anything) just to see if it executes properly.

  • Update your original question with the output from:

    • ls -l /usr/bin/wget
    • running 'set -x', then running
      wget -S -v -d --http-user="xxxxxx" --http-passwd="xxxxxx" http://cdaac-www.cosmic.ucar.edu/cdaac/rest/tarservice/data/cosmic2015/atmPrf/2015.001 -O cosmic_atmPrf_2015.001.tar
      making sure to obfuscate your username / password, but otherwise please show the full response.
    • Then try the same thing with set -x still in effect but use the following command which replaces wget with curl. Replace username and password with the correct ones - removing the < > and make sure you have the : between them, e.g, -u argonauts:argonautspw

      curl -v -u <username>:<password> http://cdaac-www.cosmic.ucar.edu/cdaac/rest/tarservice/data/cosmic2015/atmPrf/2015.001 -o cosmic_atmPrf_2015.001.tar

2nd update:

What is the output of echo $PATH

Did it work when you used /usr/bin/wget ?

Enter export PATH="/usr/bin:$PATH"

And then check if wget and other commands work.

  • I tried the above and am getting the following type wget wget is /usr/bin/wget ls -l /path/to/wget bash: ls-l: command not found The alias/unset command doesn't help. – AraZeph May 26 '16 at 6:15
  • There needs to be a space in that command: ls -l /usr/bin/wget<br>What happens if you type /usr/bin/wget ? Also try typing curl without any arguments (it won't do anything) just to see if it executes properly. – Argonauts May 26 '16 at 12:49

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.