M BUZZ CRAZE NEWS
// news

wget script exit abnormally with error 126

By Jessica Wood

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" -O cosmic_atmPrf_2015.00$i.tar; done
1

1 Answer

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
    /usr/bin/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

Update

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

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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