Last active
August 29, 2015 14:03
-
-
Save j-mcc1993/14644c5c85c429567d66 to your computer and use it in GitHub Desktop.
Expect Script that automatically grabs Ephemeris data from server via Telnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect | |
set env(TERM) no-resize-vt100 | |
set timeout 15 | |
set START_DATE "2014-Jun-26 03:00" | |
set END_DATE "2014-Jun-26 03:20" | |
set TIME_STEP "1m" | |
set M_BODY 301 | |
spawn telnet horizons.jpl.nasa.gov 6775 | |
expect "Horizons> " {send "load JMCCM-1\r"} | |
expect "Horizons> " {send "$M_BODY\r"} | |
expect "<cr>: " {send "E\r"} | |
expect "o,e,v,?] : " {send "\r"} | |
expect "<id>,coord,geo ] : " {send "\r"} | |
expect ">= 9999BC-Mar-14 23:46] : " {send "$START_DATE\r"} | |
expect "<= 9999-Dec-31 11:58] : " {send "$END_DATE\r"} | |
expect "ex: 10m, 1h, 1d, ? ] : " {send "$TIME_STEP\r"} | |
expect "cr=(y), n, ?] : " {send "y\r"} | |
while 1 { | |
expect { | |
"%" {send "\r"} | |
-ex "R]edisplay, ? : " break | |
} | |
} | |
send "F\r" | |
expect { | |
-re "File name : (.*)\r\r\n File type" { | |
set ftp_name $expect_out(1,string) } | |
send "X\r" | |
} | |
set timeout 30 | |
spawn ftp ssd.jpl.nasa.gov | |
expect "(ssd.jpl.nasa.gov:admin): " {send "anonymous\r"} | |
expect "Password: " {send "[email protected]\r"} | |
expect "ftp> " {send "cd /pub/ssd\r"} | |
expect "ftp> " {send "get $ftp_name\r"} | |
expect "ftp> " {send "bye\r"} | |
expect "Goodbye." {puts "FTP closed succesfully."} | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First draft, no error checking yet.