/[PAMELA software]/chewbacca/YodaProfiler/docs/retrieve_TLE.sh
ViewVC logotype

Annotation of /chewbacca/YodaProfiler/docs/retrieve_TLE.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download) (as text)
Wed Apr 4 09:55:11 2012 UTC (12 years, 7 months ago) by mocchiut
Branch: MAIN
Changes since 1.4: +8 -8 lines
File MIME type: application/x-sh
New retrieve_tle.sh script to be up to date with changes at space-track.org

1 mocchiut 1.1 #!/bin/sh
2     #
3     # Retrieve RESURS DK-1 TLE spanning from 14th June 2006 till today
4     #
5     # Author Nico De Simone 2006/10/12
6     #
7     # Modified by Emiliano Mocchiutti 2006/10/17
8     #
9    
10     USER=pam2006
11     PASS=Resurs05
12     OUTFILE=tle.txt
13     FORCE="no"
14    
15    
16     if [ $# -gt 0 ]; then
17     for INPUT in $*; do
18     if [ $INPUT == "--help" ] || [ $INPUT == "-h" ]; then
19     echo ""
20     echo " Usage: ./retrieve_TLE.sh [options] "
21     echo ""
22     echo " Options: "
23     echo ""
24     echo " --user=username : spacetrack username [default pam2006] "
25     echo ""
26     echo " --psw=password : spacetrack password [default Resurs150606]"
27     echo ""
28     echo " --output=filename : output filename [default tle.txt]"
29     echo ""
30     echo " --force : override existing output file [default no]"
31     echo ""
32     # Check wget
33     if [[ -z `which wget` ]]; then
34     echo "ERROR: please install wget to use this script!"
35     exit 1
36     fi
37     exit 0
38     fi
39     TEST=`echo $INPUT | sed 's/--user=//g'`
40     if [ $TEST != $INPUT ]; then
41     USER=`echo $TEST`
42     export USER;
43     fi
44     TEST=`echo $INPUT | sed 's/--psw=//g'`
45     if [ $TEST != $INPUT ]; then
46     PASS=`echo $TEST`
47     export PASS;
48     fi
49     TEST=`echo $INPUT | sed 's/--output=//g'`
50     if [ $TEST != $INPUT ]; then
51     OUTFILE=`echo $TEST`
52     export OUTFILE;
53     fi
54     if [ $INPUT == "--force" ]; then
55     FORCE="yes"
56     export FORCE;
57     fi
58     done
59     fi
60    
61     # Check wget
62     if [[ -z `which wget` ]]; then
63     echo "ERROR: please install wget to use this script!"
64     exit 1
65     fi
66    
67     if [ -f $OUTFILE ] && [ "$FORCE" == "no" ]; then
68     echo ""
69     echo " ERROR: TLE file $OUTFILE already exists (use --force)"
70     echo ""
71     exit 1
72     fi;
73    
74     YEAR=`date +%Y`
75     MONTH=`date +%m`
76     DAY=`date +%d`
77    
78     echo ""
79     echo " Today is $YEAR/$MONTH/$DAY"
80    
81     echo ""
82     echo " Setting cookies to connect to spacetrack "
83 mocchiut 1.5 wget -o /dev/null -O /dev/null --no-check-certificate --save-cookies .cookies.txt \
84     "https://www.space-track.org/perl/login.pl?_submitted=1&username=$USER&password=$PASS"
85 mocchiut 1.1 echo " Done!"
86     echo ""
87    
88 mocchiut 1.2 echo " Retrieving Resurs-DK1 TLEs 2006-2009"
89 mocchiut 1.5 wget -o /dev/null -O - --no-check-certificate --load-cookies .cookies.txt \
90 mocchiut 1.1 --save-cookies .cookies.txt --keep-session-cookies \
91 mocchiut 1.5 "https://www.space-track.org/perl/id_query.pl?_submitted=1&_sessionid=&ids=29228&timeframe=timespan&start_year=2006&start_month=6&start_day=14&end_year=2009&end_month=12&end_day=31&common_name=yes&sort=&descending=&ascii=yes&_submit=Submit&_reset=Reset "\
92 mocchiut 1.1 | egrep "1|2|R" > .tleretrieved.txt
93 mocchiut 1.4 echo " Retrieving Resurs-DK1 TLEs 2010-2011"
94 mocchiut 1.5 wget -o /dev/null -O - --no-check-certificate --load-cookies .cookies.txt \
95 mocchiut 1.2 --save-cookies .cookies.txt --keep-session-cookies \
96 mocchiut 1.5 "https://www.space-track.org/perl/id_query.pl?_submitted=1&_sessionid=&ids=29228&timeframe=timespan&start_year=2010&start_month=1&start_day=1&end_year=2011&end_month=12&end_day=31&common_name=yes&sort=&descending=&ascii=yes&_submit=Submit&_reset=Reset"\
97 mocchiut 1.4 | egrep "1|2|R" >> .tleretrieved.txt
98     echo " Retrieving Resurs-DK1 TLEs >=2012"
99 mocchiut 1.5 wget -o /dev/null -O - --no-check-certificate --load-cookies .cookies.txt \
100 mocchiut 1.4 --save-cookies .cookies.txt --keep-session-cookies \
101 mocchiut 1.5 "https://www.space-track.org/perl/id_query.pl?_submitted=1&_sessionid=&ids=29228&timeframe=timespan&start_year=2012&start_month=1&start_day=1&end_year=$YEAR&end_month=$MONTH&end_day=$DAY&common_name=yes&sort=&descending=&ascii=yes&_submit=Submit&_reset=Reset "\
102 mocchiut 1.2 | egrep "1|2|R" >> .tleretrieved.txt
103 mocchiut 1.1 echo " Done!"
104     echo ""
105    
106     CHECK=`grep -i resurs .tleretrieved.txt `
107     if [[ `wc -l < .tleretrieved.txt` -le 2 ]] || [ "$CHECK" == "" ]; then # no tle
108     echo "ERROR: No tle retrieved from spacetrack.org"
109     echo ""
110     rm -f .cookies.txt
111     rm -f .tleretrieved.txt
112     exit 1
113     fi
114    
115     cp .tleretrieved.txt $OUTFILE
116    
117     echo " File saved as $OUTFILE"
118     echo ""
119     rm -f .cookies.txt
120     rm -f .tleretrieved.txt
121     exit 0

  ViewVC Help
Powered by ViewVC 1.1.23