wget script exit abnormally with error 126
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 wgetls -l /path/to/wgetyou 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/wgetIf the last
xin-rwxr-xr-xis 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 runninglocate bin/wget; as root runchmod a+x /path/to/wget.If the
type wgetcommand 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 wgetorunset wgetto clear them, or just update your script to use the full path to wget (which wgetshould 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 -xIn your command, change the
-qto a-S -v -dto get detailed information from wget. Run the command and review the output - there may be a clue there.Use
set +xto turn off the bashing command echoing
Update
Regarding your comment: There needs to be a space in that command:
ls -l /usr/bin/wgetWhat 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 -xstill 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:argonautspwcurl -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