#!/usr/bin/perl -w ################################################################# # Perl Script to retrieve 32 online Data files of 'ds084.1', # total 6.79G. 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 schuster@ucar.edu (Doug Schuster) for further assistance. ################################################################# use strict; my ($syscmd, $vn, $opt, $i, @filelist); my $pswd = (@ARGV ? $ARGV[0] : $ENV{RDAPSWD}="05250525"); if(!$pswd) { print "\n Usage: ./op_getGFS.sh YourPassword\n\n"; exit 1; } open VN, "wget -V |" or die 'cannot find wget'; $vn = ( =~ /^GNU Wget (\d+)\.(\d+)/) ? (100 * $1 + $2) : 109; close(VN); $syscmd = ($vn > 109 ? 'wget --no-check-certificate' : 'wget'); $syscmd .= ' -O Authentication.log --save-cookies auth.rda_ucar_edu --post-data' . "=\"email=yhtseng\@ucdavis.edu&passwd=$pswd&action=login\" " . 'https://rda.ucar.edu/cgi-bin/login'; system($syscmd); $opt = 'wget -N -q'; $opt .= ' --no-check-certificate' if($vn > 109); $opt .= ' --load-cookies auth.rda_ucar_edu ' . 'http://rda.ucar.edu/data/ds084.1/'; @filelist = ( "2017/20170518/gfs.0p25.2017051800.f000.grib2", ); for($i = 0; $i < @filelist; $i++) { $syscmd = $opt . $filelist[$i]; print "$syscmd...\n"; system($syscmd); } system('rm -f auth.rda_ucar_edu Authentication.log'); exit 0;