Skip to content

Instantly share code, notes, and snippets.

@mtorrisi
Created May 24, 2017 16:46
Show Gist options
  • Save mtorrisi/380ea4af805494fc85dc668dff46ec12 to your computer and use it in GitHub Desktop.
Save mtorrisi/380ea4af805494fc85dc668dff46ec12 to your computer and use it in GitHub Desktop.
#!/bin/csh
#################################################################
# Csh Script to retrieve 45 online Data files of 'ds083.2',
# total 867.77M. This script uses 'wget' to download data.
#
# Highlight this script by Select All, Copy and Paste it into a file;
# make the file executable and run it on command line.
#
# You need pass in your password as a parameter to execute
# this script; or you can set an environment variable RDAPSWD
# if your Operating System supports it.
#
# Contact [email protected] (Grace Peng) for further assistance.
#################################################################
set pswd = $1
if(x$pswd == x && `env | grep RDAPSWD` != '') then
set pswd = $RDAPSWD
endif
if(x$pswd == x) then
echo
echo Usage: $0 YourPassword
echo
exit 1
endif
set v = `wget -V |grep 'GNU Wget ' | cut -d ' ' -f 3`
set a = `echo $v | cut -d '.' -f 1`
set b = `echo $v | cut -d '.' -f 2`
if(100 * $a + $b > 109) then
set opt = 'wget --no-check-certificate'
else
set opt = 'wget'
endif
set opt1 = '-O Authentication.log --save-cookies auth.rda_ucar_edu --post-data'
set opt2 = "email=<[email protected]>&passwd=$pswd&action=login"
$opt $opt1="$opt2" https://rda.ucar.edu/cgi-bin/login
set opt1 = "-N --load-cookies auth.rda_ucar_edu"
set opt2 = "$opt $opt1 http://rda.ucar.edu/data/ds083.2/"
set filelist = ( \
grib2/2017/2017.05/fnl_20170511_00_00.grib2 \
grib2/2017/2017.05/fnl_20170511_06_00.grib2 \
grib2/2017/2017.05/fnl_20170511_12_00.grib2 \
grib2/2017/2017.05/fnl_20170511_18_00.grib2 \
grib2/2017/2017.05/fnl_20170512_00_00.grib2 \
grib2/2017/2017.05/fnl_20170512_06_00.grib2 \
grib2/2017/2017.05/fnl_20170512_12_00.grib2 \
grib2/2017/2017.05/fnl_20170512_18_00.grib2 \
grib2/2017/2017.05/fnl_20170513_00_00.grib2 \
grib2/2017/2017.05/fnl_20170513_06_00.grib2 \
grib2/2017/2017.05/fnl_20170513_12_00.grib2 \
grib2/2017/2017.05/fnl_20170513_18_00.grib2 \
grib2/2017/2017.05/fnl_20170514_00_00.grib2 \
grib2/2017/2017.05/fnl_20170514_06_00.grib2 \
grib2/2017/2017.05/fnl_20170514_12_00.grib2 \
grib2/2017/2017.05/fnl_20170514_18_00.grib2 \
grib2/2017/2017.05/fnl_20170515_00_00.grib2 \
grib2/2017/2017.05/fnl_20170515_06_00.grib2 \
grib2/2017/2017.05/fnl_20170515_12_00.grib2 \
grib2/2017/2017.05/fnl_20170515_18_00.grib2 \
grib2/2017/2017.05/fnl_20170516_00_00.grib2 \
grib2/2017/2017.05/fnl_20170516_06_00.grib2 \
grib2/2017/2017.05/fnl_20170516_12_00.grib2 \
grib2/2017/2017.05/fnl_20170516_18_00.grib2 \
grib2/2017/2017.05/fnl_20170517_00_00.grib2 \
grib2/2017/2017.05/fnl_20170517_06_00.grib2 \
grib2/2017/2017.05/fnl_20170517_12_00.grib2 \
grib2/2017/2017.05/fnl_20170517_18_00.grib2 \
grib2/2017/2017.05/fnl_20170518_00_00.grib2 \
grib2/2017/2017.05/fnl_20170518_06_00.grib2 \
grib2/2017/2017.05/fnl_20170518_12_00.grib2 \
grib2/2017/2017.05/fnl_20170518_18_00.grib2 \
grib2/2017/2017.05/fnl_20170519_00_00.grib2 \
grib2/2017/2017.05/fnl_20170519_06_00.grib2 \
grib2/2017/2017.05/fnl_20170519_12_00.grib2 \
grib2/2017/2017.05/fnl_20170519_18_00.grib2 \
grib2/2017/2017.05/fnl_20170520_00_00.grib2 \
grib2/2017/2017.05/fnl_20170520_06_00.grib2 \
grib2/2017/2017.05/fnl_20170520_12_00.grib2 \
grib2/2017/2017.05/fnl_20170520_18_00.grib2 \
grib2/2017/2017.05/fnl_20170521_00_00.grib2 \
grib2/2017/2017.05/fnl_20170521_06_00.grib2 \
grib2/2017/2017.05/fnl_20170521_12_00.grib2 \
grib2/2017/2017.05/fnl_20170521_18_00.grib2 \
grib2/2017/2017.05/fnl_20170522_00_00.grib2 \
)
while($#filelist > 0)
set syscmd = "$opt2$filelist[1]"
echo "$syscmd ..."
$syscmd
shift filelist
end
rm -f auth.rda_ucar_edu Authentication.log
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment