Download a File with cURL or Wget

Please enter here to ask a question about any NASA Science related topics!
Post Reply
njester
Posts: 8
Joined: Sat Mar 06, 2021 9:03 am America/New_York

Download a File with cURL or Wget

by njester » Mon May 24, 2021 11:35 am America/New_York

The following allows you to download data from https://asdc.larc.nasa.gov/data/ using linux, a mac, or Windows with Cygin.

1) If you haven't before, create an authentication cookie that can be used with to access files behind the EarthData login page.

Code: Select all

USERNAME=<your earthdata username>
PASSWORD=<your earthdata password>
cd ~ 
touch .netrc 
echo "machine urs.earthdata.nasa.gov login $USERNAME password $PASSWORD" > .netrc 
chmod 0600 .netrc 
touch .urs_cookies 
2) You can download data with the following commands:

Code: Select all

URL=<your url here>
curl -b ~/.urs_cookies -c ~/.urs_cookies --remote-name --location  --netrc $URL
or

Code: Select all

wget --load-cookies ~/.urs_cookies --save-cookies ~/.urs_cookies --auth-no-challenge=on --keep-session-cookies --content-disposition $URL
You can learn more about these command line tools here:
https://www.gnu.org/software/wget/
https://curl.se/docs/
https://wiki.earthdata.nasa.gov/display ... L+And+Wget

Tags:

Post Reply