-
Notifications
You must be signed in to change notification settings - Fork 0
/
sightings
executable file
·62 lines (55 loc) · 1.28 KB
/
sightings
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/gawk -f
BEGIN {
ORS = "\r\n"
sock = "/inet/tcp/0/spotthestation.nasa.gov/http"
print "GET /sightings/xml_files/Portugal_None_Lisbon.xml HTTP/1.1" |& sock
print "Host: spotthestation.nasa.gov" |& sock
print "" |& sock
while (sock |& getline && $1 != "<?xml");
while (sock |& getline && $1 != 0) {
sub("°", "º", $0)
sub("<.*", "", $0)
gsub(",", "", $0)
switch($1) {
case /<title>/:
sub(".*<title>", "", $0)
sub("</title>", "", $0)
date = $1
title = $0
break
case "Date:":
dayw = substr($2, 0, 3)
break
case "Time:":
time = $2
apm = $3
break
case "Duration:":
sub(".*Duration: ", "", $0)
dur = $0
break
case "Maximum":
max = $3
break
case "Approach:":
sub(".*Approach: ", "", $0)
app = $0
break
case "Departure:":
sub(".*Departure: ", "", $0)
dep = $0
break
case "</item>":
s = sprintf("%s %-32s %s %s %-10s %-20s %-20s %s", dayw, title, time, apm, max, app, dep, dur);
if (apm == "AM")
s = "\033[38;5;240m"s"\033[0m" # gray
else if (date == strftime("%Y-%m-%d", systime())) {
if (ARGV[1] == "mail")
print s | "mail root -s '### ISS sighting today ###'"
s = "\033[38;5;46m"s"\033[0m" # green
}
print s
break
}
}
}