aboutsummaryrefslogtreecommitdiff
path: root/src/cal/get_tle/GetTLE.java
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-03-07 23:42:46 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-03-07 23:42:46 -0500
commit727498350ee97618f5a23f93addaef43e7d950af (patch)
treeea77abba309c71e438bbf3fd5aa600c86116e7f9 /src/cal/get_tle/GetTLE.java
parentece6c047eacb388ed4d36ce1eb18cc96b47a047e (diff)
downloadcalfuse-727498350ee97618f5a23f93addaef43e7d950af.tar.gz
Massive fixes. Adding the rest of the code.
Diffstat (limited to 'src/cal/get_tle/GetTLE.java')
-rw-r--r--src/cal/get_tle/GetTLE.java110
1 files changed, 0 insertions, 110 deletions
diff --git a/src/cal/get_tle/GetTLE.java b/src/cal/get_tle/GetTLE.java
deleted file mode 100644
index 68e88d3..0000000
--- a/src/cal/get_tle/GetTLE.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * GetTLE.java
- *
- * Created on January 16, 2005, 8:34 PM
- */
-import java.net.URL;
-import java.net.URLConnection;
-import java.io.*;
-
-import java.util.Map;
-import java.util.List;
-/**
- *
- * @author fred
- */
-public class GetTLE {
-
- /** Creates a new instance of GetTLE */
- public GetTLE() {
- }
-
- /**
- * @param args the command line arguments
- */
- static final String host="www.space-track.org";
- static final String loginURL="/perl/login.pl";
- static final String dataURL="/perl/id_query.pl?ids=25791&timeframe=last5&common_name=yes&sort=catnum&descending=yes&ascii=yes&_submit=Submit&_submitted=1";
- static final String username="mromelfanger";
- static final String password="FuseJHU1";
-
- static final String outputFile = "/data1/fuse/calfuse/caltemp/five.tle";
- static final String logFile = "/data1/fuse/calfuse/caltemp/get_tle.logfile";
-/*
- static final String outputFile = "/caltemp/five.tle";
- static final String logFile = "/caltemp/get_tle.logfile";
-*/
- public static void main(String[] args) {
- // TODO code application logic here
- try {
- /*
- * Open the login url and get the session cookie back.
- */
- PrintWriter log = new PrintWriter(new OutputStreamWriter(new FileOutputStream(logFile)));
- PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(outputFile)));
-
- URL u = new URL("http://"+host+loginURL+"?username="+username+"&password="+password+"&_submitted=1&_submit=Submit");
-
- URLConnection c = u.openConnection();
- Map m = c.getHeaderFields();
- List l = (List) m.get("Set-Cookie");
- String session = null;
- for(int i=0;i!=l.size();i++) {
- String s = (String) l.get(i);
- if(s.startsWith("spacetrack_session=")) {
- int end = s.indexOf(";");
- if(end < 0)
- end = s.length();
- session = s.substring(0, end);
- break;
- }
- }
- InputStream is = c.getInputStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(is));
- String s;
- while((s = br.readLine()) != null)
- log.println(s);
- is.close();
-
- if(session == null) {
- out.println("Could not get session id");
- System.exit(1);
- }
-
- /*
- * Use the session cookie to query for the fuse data.
- */
-
- u = new URL("http://"+host+dataURL);
- c = u.openConnection();
- c.setRequestProperty("Cookie", session);
- is = c.getInputStream();
- br = new BufferedReader(new InputStreamReader(is));
- /*
- * Read each line and keep what is between the pre's, add an extra
- * line at the end.
- */
- boolean collect = false;
- out.println();
- while((s = br.readLine()) != null) {
- log.println(s);
- if(s.startsWith("<pre>")) {
-/* br.readLine(); */
- collect = true;
- } else if(s.startsWith("</pre>")) {
- break;
- } else if(collect) {
- out.println(s);
- }
- }
- out.println();
- br.close();
- is.close();
- out.close();
- log.close();
-
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
-}