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 |
mocchiut |
1.2 |
PASS=Resurs05 |
12 |
mocchiut |
1.1 |
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 -o /dev/null -O /dev/null --save-cookies .cookies.txt \ |
84 |
|
|
http://www.space-track.org/perl/login.pl --post-data="_submitted=1&username=$USER&password=$PASS" |
85 |
|
|
echo " Done!" |
86 |
|
|
echo "" |
87 |
|
|
|
88 |
|
|
echo " Retrieving Resurs-DK1 TLEs " |
89 |
|
|
wget -o /dev/null -O - --load-cookies .cookies.txt \ |
90 |
|
|
--save-cookies .cookies.txt --keep-session-cookies \ |
91 |
|
|
http://www.space-track.org/perl/id_query.pl --post-data="_submitted=1&_sessionid=&ids=29228&timeframe=timespan&start_year=2006&start_month=6&start_day=14&end_year=$YEAR&end_month=$MONTH&end_day=$DAY&common_name=yes&sort=&descending=&ascii=yes&_submit=Submit&_reset=Reset" \ |
92 |
|
|
| egrep "1|2|R" > .tleretrieved.txt |
93 |
|
|
echo " Done!" |
94 |
|
|
echo "" |
95 |
|
|
|
96 |
mocchiut |
1.3 |
CHECK=`grep -i resurs .tleretrieved.txt ` |
97 |
|
|
if [[ `wc -l < .tleretrieved.txt` -le 2 ]] || [ "$CHECK" == "" ]; then # no tle |
98 |
mocchiut |
1.1 |
echo "ERROR: No tle retrieved from spacetrack.org" |
99 |
|
|
echo "" |
100 |
|
|
rm -f .cookies.txt |
101 |
|
|
rm -f .tleretrieved.txt |
102 |
|
|
exit 1 |
103 |
|
|
fi |
104 |
|
|
|
105 |
|
|
cp .tleretrieved.txt $OUTFILE |
106 |
|
|
|
107 |
|
|
echo " File saved as $OUTFILE" |
108 |
|
|
echo "" |
109 |
|
|
rm -f .cookies.txt |
110 |
|
|
rm -f .tleretrieved.txt |
111 |
|
|
exit 0 |