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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download) (as text)
Wed Jun 3 08:10:45 2015 UTC (9 years, 5 months ago) by mocchiut
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +1 -1 lines
File MIME type: application/x-sh
New space track password

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 wget --post-data='identity=pam2006&password=Resurs_150606!!' --cookies=on --keep-session-cookies --save-cookies=.cookies.txt 'https://www.space-track.org/ajaxauth/login' -o/dev/null
84 #wget -o /dev/null -O /dev/null --no-check-certificate --save-cookies .cookies.txt \
85 #"https://www.space-track.org/perl/login.pl?_submitted=1&username=$USER&password=$PASS"
86 echo " Done!"
87 echo ""
88
89 echo " Retrieving Resurs-DK1 TLEs 2006-2009"
90 wget -o /dev/null -O - --limit-rate=100K --no-check-certificate --load-cookies .cookies.txt \
91 --save-cookies .cookies.txt --keep-session-cookies \
92 "https://www.space-track.org/basicspacedata/query/class/tle/EPOCH/2006-06-14--2009-12-31/NORAD_CAT_ID/29228/orderby/TLE_LINE1 ASC/format/3le"\
93 #"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 "\
94 | egrep "1|2|R" > .tleretrieved.txt
95 echo " Retrieving Resurs-DK1 TLEs 2010-2011"
96 wget -o /dev/null -O - --limit-rate=100K --no-check-certificate --load-cookies .cookies.txt \
97 --save-cookies .cookies.txt --keep-session-cookies \
98 "https://www.space-track.org/basicspacedata/query/class/tle/EPOCH/2010-01-01--2011-12-31/NORAD_CAT_ID/29228/orderby/TLE_LINE1 ASC/format/3le"\
99 #"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"\
100 | egrep "1|2|R" >> .tleretrieved.txt
101 echo " Retrieving Resurs-DK1 TLEs >=2012"
102 wget -o /dev/null -O - --limit-rate=100K --no-check-certificate --load-cookies .cookies.txt \
103 --save-cookies .cookies.txt --keep-session-cookies \
104 "https://www.space-track.org/basicspacedata/query/class/tle/EPOCH/2012-01-01--$YEAR-$MONTH-$DAY/NORAD_CAT_ID/29228/orderby/TLE_LINE1 ASC/format/3le"\
105 #"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 "\
106 | egrep "1|2|R" >> .tleretrieved.txt
107 echo " Done!"
108 echo ""
109
110 CHECK=`grep -i resurs .tleretrieved.txt `
111 if [[ `wc -l < .tleretrieved.txt` -le 2 ]] || [ "$CHECK" == "" ]; then # no tle
112 echo "ERROR: No tle retrieved from spacetrack.org"
113 echo ""
114 # rm -f .cookies.txt
115 # rm -f login
116 # rm -f .tleretrieved.txt
117 exit 1
118 fi
119
120 #cp .tleretrieved.txt $OUTFILE
121
122 cat .tleretrieved.txt | sed 's/0 RESURS DK-1/RESURS DK-1/g' | sed -e 's/\r//g' > $OUTFILE
123
124 echo " File saved as $OUTFILE"
125 echo ""
126 rm -f login
127 rm -f .cookies.txt
128 rm -f .tleretrieved.txt
129 exit 0

  ViewVC Help
Powered by ViewVC 1.1.23