Update {astro,mpcorb}2edb.pl Perl scripts to HTTPS

This commit is contained in:
R. J. Mathar 2021-11-22 14:09:38 -05:00 committed by Brandon Rhodes
parent b27947efcd
commit aaaea1edc5
2 changed files with 29 additions and 20 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl #!/usr/bin/perl
# convert astorb.txt to 2 .edb files. # convert astorb.txt to 2 .edb files.
# Usage: [-f] <base> # Usage: [-f] <base>
# if -f then use ftp to get the script from lowell, else read it from stdin. # if -f then use curl to get the script from lowell, else read it from stdin.
# <base> is a prefix used in naming the generated .edb files. # <base> is a prefix used in naming the generated .edb files.
# Two files are created: # Two files are created:
# <base>.edb contains only those asteroids which might ever be brighter # <base>.edb contains only those asteroids which might ever be brighter
@ -9,7 +9,7 @@
# <base>_dim.edb contains the remaining asteroids. # <base>_dim.edb contains the remaining asteroids.
# #
# astorb is a set of elements for 30k+ asteroids maintained by Lowell # astorb is a set of elements for 30k+ asteroids maintained by Lowell
# Observatory. See ftp://ftp.lowell.edu/pub/elgb/astorb.html. From the # Observatory. See https://ftp.lowell.edu/pub/elgb/astorb.html. From the
# Acknowledgments section of same: # Acknowledgments section of same:
# The research and computing needed to generate astorb.dat were funded # The research and computing needed to generate astorb.dat were funded
# principally by NASA grant NAGW-1470, and in part by the Lowell Observatory # principally by NASA grant NAGW-1470, and in part by the Lowell Observatory
@ -18,7 +18,7 @@
# made. # made.
# #
# grab RCS version # grab RCS version
my $ver = '$Revision: 1.1 $'; my $ver = '$Revision: 1.2 $';
$ver =~ s/\$//g; $ver =~ s/\$//g;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $me); my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $me);
my $XCN=<<EOF; my $XCN=<<EOF;
@ -30,9 +30,9 @@ my $XCN=<<EOF;
# ephemeris uncertainties, and some additional data for all the numbered asteroids # ephemeris uncertainties, and some additional data for all the numbered asteroids
# and the vast majority of unnumbered asteroids (multi-apparition and single-ap- # and the vast majority of unnumbered asteroids (multi-apparition and single-ap-
# parition) for which it is possible to make reasonably determinate computations. # parition) for which it is possible to make reasonably determinate computations.
# It is currently about 1.7 Mb in size in its compressed form(astorb.dat.gz) # It is currently about 83 Mb in size in its compressed form(astorb.dat.gz)
# 6.3 Mb in size when decompressed (astorb.dat), and contains 237215 orbits # 305 Mb in size when decompressed (astorb.dat).
# computed by me (Edward Bowell). Each orbit, based on astrometric observations # Each orbit, based on astrometric observations
# downloaded from the Minor Planet Center, occupies one 266-column record. # downloaded from the Minor Planet Center, occupies one 266-column record.
# #
# Special Features of astorb.dat # Special Features of astorb.dat
@ -49,7 +49,7 @@ my $XCN=<<EOF;
# #
# Second, all the orbits in a given version of the file have an epoch of # Second, all the orbits in a given version of the file have an epoch of
# osculation near the present. Consequently, the ephemerides of most non-Earth- # osculation near the present. Consequently, the ephemerides of most non-Earth-
# -approaching asteroids can be computed to arcsec accuracy or better within ± 50 # -approaching asteroids can be computed to arcsec accuracy or better within ± 50
# days of the epoch using a 2-body ephemeris program. # days of the epoch using a 2-body ephemeris program.
# #
# Third, current and future ephemeris uncertainties are given.Observers will # Third, current and future ephemeris uncertainties are given.Observers will
@ -63,7 +63,7 @@ my $XCN=<<EOF;
# #
# AstLowell.edb # AstLowell.edb
# astorb is a set of elements for 30k+ asteroids maintained by Lowell # astorb is a set of elements for 30k+ asteroids maintained by Lowell
# Observatory. See ftp://ftp.lowell.edu/pub/elgb/astorb.html. From the # Observatory. See https://ftp.lowell.edu/pub/elgb/astorb.html. From the
# Acknowledgments section of same: # Acknowledgments section of same:
# The research and computing needed to generate astorb.dat were funded # The research and computing needed to generate astorb.dat were funded
# principally by NASA grant NAGW-1470, and in part by the Lowell Observatory # principally by NASA grant NAGW-1470, and in part by the Lowell Observatory
@ -117,7 +117,7 @@ print "Creating $brtfn and $dimfn..\n";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime;
$year += 1900; $year += 1900;
$mon += 1; $mon += 1;
$from = "# Data From ftp://ftp.lowell.edu/pub/elgb/astorb.dat.gz\n"; $from = "# Data From https://ftp.lowell.edu/pub/elgb/astorb.dat.gz\n";
$what = "# Generated by astorb2edb.pl $ver, (c) 2000 Elwood Downey\n"; $what = "# Generated by astorb2edb.pl $ver, (c) 2000 Elwood Downey\n";
$when = "# Processed $year-$mon-$mday $hour:$min:$sec UTC\n"; $when = "# Processed $year-$mon-$mday $hour:$min:$sec UTC\n";
@ -233,9 +233,19 @@ sub fetch
{ {
# transfer # transfer
print "Getting $ORBFTPDIR/$ORBGZFILE from $ORBSITE...\n"; print "Getting $ORBFTPDIR/$ORBGZFILE from $ORBSITE...\n";
$cmd = "curl -s --connect-timeout 10 -u 'anonymous:xephem\@clearskyinstitute.com' $ORBSITE/$ORBFTPDIR/$ORBGZFILE > $ORBGZFILE"; $cmd_v1 = "curl -s --connect-timeout 10 -u 'anonymous:xephem\@github.com' https://$ORBSITE/$ORBFTPDIR/$ORBGZFILE > $ORBGZFILE";
print "$cmd\n"; $cmd_v2 = "curl -s --disable-epsv --connect-timeout 10 -u 'anonymous:xephem\@github.com' https://$ORBSITE/$ORBFTPDIR/$ORBGZFILE > $ORBGZFILE";
!system "$cmd" or exit(1); print "trying $cmd_v1\n";
$curl_return = system "$cmd_v1";
$curl_return = $curl_return >> 8;
if ($curl_return != 0) {
print "trying $cmd_v2\n";
$curl_return = system "$cmd_v2";
$curl_return = $curl_return >> 8;
}
if ($curl_return != 0) {
die "curl failed\n";
}
# explode # explode
print "Decompressing $ORBGZFILE ...\n"; print "Decompressing $ORBGZFILE ...\n";
@ -246,4 +256,3 @@ sub fetch
# flag # flag
$fetchok = 1; $fetchok = 1;
} }

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl #!/usr/bin/perl
# convert MPCORB.DAT to 2 .edb files. # convert MPCORB.DAT to 2 .edb files.
# Usage: [-f] <base> # Usage: [-f] <base>
# if -f then use ftp to get the script from harvard, else read it from stdin. # if -f then use curl to get the script from harvard, else read it from stdin.
# <base> is a prefix used in naming the generated .edb files. # <base> is a prefix used in naming the generated .edb files.
# Two files are created: # Two files are created:
# <base>.edb contains only those asteroids which might ever be brighter # <base>.edb contains only those asteroids which might ever be brighter
@ -9,7 +9,7 @@
# <base>_dim.edb contains the remaining asteroids. # <base>_dim.edb contains the remaining asteroids.
# #
# mpcorb.dat is a service of the Minor Planet Center, # mpcorb.dat is a service of the Minor Planet Center,
# http://cfa-www.harvard.edu/cfa/ps/mpc.html. # https://www.minorplanetcenter.net/iau/MPCORB
# #
# Copyright (c) 2000 Elwood Downey # Copyright (c) 2000 Elwood Downey
# 16 Mar 1999: first draft # 16 Mar 1999: first draft
@ -20,6 +20,7 @@
# 24 Sep 2004: only remove files if downloaded fresh # 24 Sep 2004: only remove files if downloaded fresh
# 1 Nov 2012: change from ftp to curl for better error handling. # 1 Nov 2012: change from ftp to curl for better error handling.
# 4 Jul 2014: change download site # 4 Jul 2014: change download site
# 12 Oct 2021: access to https: (R. J. Mathar)
# grab RCS version # grab RCS version
my $ver = '$Revision: 1.3 $'; my $ver = '$Revision: 1.3 $';
@ -33,7 +34,7 @@ my $XCN=<<EOF;
# --------------------------- # ---------------------------
# MPC Orbit Database # MPC Orbit Database
# * The MPC Orbit Database (MPCORB) is available for downloading from the anon-ftp # * The MPC Orbit Database (MPCORB) is available for downloading from the anon-ftp
# link ftp://cfa-ftp.harvard.edu/pub/MPCORB/. # link https://www.minorplanetcenter.net/iau/MPCORB/.
# Download either the complete file or daily updates. # Download either the complete file or daily updates.
# * Note that the security features used in this ftp server require that your # * Note that the security features used in this ftp server require that your
# machine be found in a "reverse DNS lookup" in order to access this site. A # machine be found in a "reverse DNS lookup" in order to access this site. A
@ -67,7 +68,7 @@ my $XCN=<<EOF;
# acknowledged. # acknowledged.
# #
# New versions of this file, updated on a daily basis,will be available # New versions of this file, updated on a daily basis,will be available
# at: ftp://cfa-ftp.harvard.edu/pub/MPCORB/MPCORB.DAT # at: https://www.minorplanetcenter.net/iau/MPCORB/MPCORB.DAT
# These files are rebuilt each night, generally between 02:00 and # These files are rebuilt each night, generally between 02:00 and
# 03:00 EST (07:00 and 08:00 UT), except during the short period each # 03:00 EST (07:00 and 08:00 UT), except during the short period each
# month when the next batch of Minor Planet Circulars are being # month when the next batch of Minor Planet Circulars are being
@ -79,7 +80,7 @@ EOF
my $dimmag = 13; # dimmest mag to be saved in "bright" file my $dimmag = 13; # dimmest mag to be saved in "bright" file
# set site and file in case of -f # set site and file in case of -f
my $MPCSITE = "https://www.minorplanetcenter.net"; my $MPCSITE = "https://www.minorplanetcenter.net";
my $MPCFTPDIR = "/iau/MPCORB"; my $MPCFTPDIR = "iau/MPCORB";
my $MPCFILE = "MPCORB.DAT"; my $MPCFILE = "MPCORB.DAT";
my $MPCZIPFILE = "MPCORB.DAT.gz"; my $MPCZIPFILE = "MPCORB.DAT.gz";
my $MPCOUTFILE = "AstMPC"; my $MPCOUTFILE = "AstMPC";
@ -247,7 +248,7 @@ sub fetch
{ {
# transfer # transfer
print "Getting $MPCFTPDIR/$MPCZIPFILE from $MPCSITE...\n"; print "Getting $MPCFTPDIR/$MPCZIPFILE from $MPCSITE...\n";
$cmd = "curl -connect-timeout 10 -s -u 'anonymous:xephem\@clearskyinstitute.com' $MPCSITE/$MPCFTPDIR/$MPCZIPFILE > $MPCZIPFILE"; $cmd = "curl -connect-timeout 10 -s -u 'anonymous:xephem\@github.com' $MPCSITE/$MPCFTPDIR/$MPCZIPFILE > $MPCZIPFILE";
print "$cmd\n"; print "$cmd\n";
!system "$cmd" or exit(1); !system "$cmd" or exit(1);
@ -260,4 +261,3 @@ sub fetch
# flag # flag
$fetchok = 1; $fetchok = 1;
} }