爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3768|回复: 0

[grib] linux每天自动下载前天fnl数据的csh脚本

[复制链接]

新浪微博达人勋

发表于 2022-9-23 11:39:44 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x

基于官方下载脚本简单改了个可以自动下载的csh,结合crontab命令可以做到每天全自动下载
数据选择前天的是因为前天数据时段比较全

脚本如下,自己修改一下账号密码就行,把这个cshell加入crontab就行,百度一下都有教程


#!/bin/csh
#################################################################
# Csh Script to retrieve 5 online Data files of 'ds083.2',
# total 194.62M. 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 rdahelp@ucar.edu (RDA help desk) for further assistance.
#################################################################
set email= 这里改成你自己注册的邮箱
set pswd = 这里改成你自己的密码
set date1=`date  -d "-2 day" +%Y%m%d`
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&passwd=$pswd&action=login"
$opt $opt1="$opt2" https://rda.ucar.edu/cgi-bin/login
if ( $status == 6 ) then
echo 'Please check that your password is correct.'
echo "Usage: $0 YourPassword"
exit 1
endif
set opt1 = "-N --load-cookies auth.rda_ucar_edu"
set opt2 = "$opt $opt1 https://rda.ucar.edu/data/ds083.2/"
set filelist = ( \
  grib2/2022/2022.09/fnl_${date1}_00_00.grib2 \
  grib2/2022/2022.09/fnl_${date1}_06_00.grib2 \
  grib2/2022/2022.09/fnl_${date1}_12_00.grib2 \
  grib2/2022/2022.09/fnl_${date1}_18_00.grib2 \
)
while($#filelist > 0)
set syscmd = "$opt2$filelist[1]"
echo "$syscmd ..."
$syscmd
shift filelist
end


密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表