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

11 visualizaciones (últimos 30 días)
Shayma Al Ali
Shayma Al Ali el 27 de Mzo. de 2023
Respondida: Walter Roberson el 27 de Mzo. de 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?

Respuestas (1)

Walter Roberson
Walter Roberson el 27 de Mzo. de 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

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by