Error: /bin/bash: wget: command not found

10 vues (au cours des 30 derniers jours)
Shayma Al Ali
Shayma Al Ali le 27 Mar 2023
Hello everyone,
I need to run a script that involves downloading a file one at a time from a list of urls, running the script, and this all done over a for-loop. I don't think I can use websave as I don't have a list of the file names, only the urls. This is the code I came up with:
urltxt=importdata("url.txt");
for r=1:length(urltxt)
urlname=urltxt{r};
%urlname=cell2mat(urlname);
!echo 'machine urs.earthdata.nasa.gov login <uid> password <pswd>' >> ~/.netrc
!chmod 0600 ~/.netrc
!wget --load-cookies ~/.urs_cookies --save-cookies ~/.urs_cookies --keep-session-cookies urlname
However, I keep getting the error: /bin/bash: wget: command not found. I have wget installed on my path and I'm able to run the code above in my terminal (OS). Any way to fix this?

Réponses (1)

Walter Roberson
Walter Roberson le 27 Mar 2023
I have wget installed on my path
If you are using MacOS, then probably, NO, you do not have it installed on your path. Probably you used .bashrc or equivalent to add directories to your PATH environment variable. That will not work because programs that are launched using icons do not start login shells, and most of the shell initialization files are only processed for login shells.
In MacOS, you can use launchctl to add to your system PATH
Or you can add the executable to /usr/bin
Or you can set the path in your ! command, such as
!PATH=/usr/local/bin:$PATH wget --load-cookies ~/.urs_cookies --save-cookies ~/.urs_cookies --keep-session-cookies urlname
Or you can name the executable directly such as
!/usr/local/bin/wget --load-cookies ~/.urs_cookies --save-cookies ~/.urs_cookies --keep-session-cookies urlname

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by