iss - International Space Station current location & sightings

hakerdefo

Good news for all those interested in astronomy and space science. I've created a silly little bash script called 'iss' that gets you the following information right in your terminal,

  • Current position of International Space Station (ISS) in latitude-longitude. And if map data is available for the current location then the script will display name-address of the location.
  • Passing date-time and duration of ISS for your location.
  • Number of people currently in space, their name(s), and the name(s) of spacecraft they are on.
Sounds interesting? Only dependency of this script is 'jq'.

sudo apt-get install jq


Here is the script 'iss',

#!/bin/bash

latit=
longi=
eleva=

curl -s --connect-timeout 30 -o /tmp/issn.json "http://api.open-notify.org/iss-now.json"
curl -s --connect-timeout 30 -o /tmp/issp.json "http://api.open-notify.org/iss-pass.json?lat=$latit&lon=$longi&alt=$eleva&n=10"
curl -s --connect-timeout 30 -o /tmp/astros.json "http://api.open-notify.org/astros.json"

issnowtu=$(cat /tmp/issn.json | jq -r '.timestamp')
issnowth=$(date -d @"$issnowtu" +'%H:%M:%S (%d-%m-%Y)')
latit=$(cat /tmp/issn.json | jq -r '.iss_position.latitude')
longi=$(cat /tmp/issn.json | jq -r '.iss_position.longitude')
isspd1=$(cat /tmp/issp.json | jq -r '.response[0].duration')
isspd11=$(printf '%d:%02d\n' $(($isspd1/60%60)) $(($isspd1%60)))
isspd2=$(cat /tmp/issp.json | jq -r '.response[1].duration')
isspd22=$(printf '%d:%02d\n' $(($isspd2/60%60)) $(($isspd2%60)))
isspd3=$(cat /tmp/issp.json | jq -r '.response[2].duration')
isspd33=$(printf '%d:%02d\n' $(($isspd3/60%60)) $(($isspd3%60)))
isspd4=$(cat /tmp/issp.json | jq -r '.response[3].duration')
isspd44=$(printf '%d:%02d\n' $(($isspd4/60%60)) $(($isspd4%60)))
isspd5=$(cat /tmp/issp.json | jq -r '.response[4].duration')
isspd55=$(printf '%d:%02d\n' $(($isspd5/60%60)) $(($isspd5%60)))
isspd6=$(cat /tmp/issp.json | jq -r '.response[5].duration')
isspd66=$(printf '%d:%02d\n' $(($isspd6/60%60)) $(($isspd6%60)))
isspd7=$(cat /tmp/issp.json | jq -r '.response[6].duration')
isspd77=$(printf '%d:%02d\n' $(($isspd7/60%60)) $(($isspd7%60)))
isspd8=$(cat /tmp/issp.json | jq -r '.response[7].duration')
isspd88=$(printf '%d:%02d\n' $(($isspd8/60%60)) $(($isspd8%60)))
isspd9=$(cat /tmp/issp.json | jq -r '.response[8].duration')
isspd99=$(printf '%d:%02d\n' $(($isspd9/60%60)) $(($isspd9%60)))
isspd10=$(cat /tmp/issp.json | jq -r '.response[9].duration')
isspd100=$(printf '%d:%02d\n' $(($isspd10/60%60)) $(($isspd10%60)))
isspt1=$(cat /tmp/issp.json | jq -r '.response[0].risetime')
isspt11=$(date -d @"$isspt1" +'%d-%m-%Y (%H:%M:%S)')
isspt2=$(cat /tmp/issp.json | jq -r '.response[1].risetime')
isspt22=$(date -d @"$isspt2" +'%d-%m-%Y (%H:%M:%S)')
isspt3=$(cat /tmp/issp.json | jq -r '.response[2].risetime')
isspt33=$(date -d @"$isspt3" +'%d-%m-%Y (%H:%M:%S)')
isspt4=$(cat /tmp/issp.json | jq -r '.response[3].risetime')
isspt44=$(date -d @"$isspt4" +'%d-%m-%Y (%H:%M:%S)')
isspt5=$(cat /tmp/issp.json | jq -r '.response[4].risetime')
isspt55=$(date -d @"$isspt5" +'%d-%m-%Y (%H:%M:%S)')
isspt6=$(cat /tmp/issp.json | jq -r '.response[5].risetime')
isspt66=$(date -d @"$isspt6" +'%d-%m-%Y (%H:%M:%S)')
isspt7=$(cat /tmp/issp.json | jq -r '.response[6].risetime')
isspt77=$(date -d @"$isspt7" +'%d-%m-%Y (%H:%M:%S)')
isspt8=$(cat /tmp/issp.json | jq -r '.response[7].risetime')
isspt88=$(date -d @"$isspt8" +'%d-%m-%Y (%H:%M:%S)')
isspt9=$(cat /tmp/issp.json | jq -r '.response[8].risetime')
isspt99=$(date -d @"$isspt9" +'%d-%m-%Y (%H:%M:%S)')
isspt10=$(cat /tmp/issp.json | jq -r '.response[9].risetime')
isspt100=$(date -d @"$isspt10" +'%d-%m-%Y (%H:%M:%S)')
astrock=$(cat /tmp/astros.json | grep "0,")

curl -s --connect-timeout 30 -o /tmp/gcd.json "https://maps.googleapis.com/maps/api/geocode/json?latlng=$latit,$longi&components=locality&language=en"

issnowl=$(cat /tmp/gcd.json | jq -r '.results[0].formatted_address')
issnowlc=$(cat /tmp/gcd.json | grep "ZERO_RESULTS")
echo ""
#echo -e "International Space Station (ISS) on $issnowth is over,"
echo -e "Current Time -> $issnowth"
echo ""
echo -e "Current Location of ISS :"
echo ""
echo -e "Latitude -> $latit"
echo -e "Longitude -> $longi"
echo ""
echo -e "In layman's term ISS is currently over the skies of,"
echo ""

if [[ -z "$issnowlc" ]]; then
echo -e "$issnowl"
else
echo -e "Some unmapped region of earth."
echo ""
fi

echo ""
echo -e "ISS will pass over your location at these times :"
echo ""
echo -e "Passing Date & Time -> $isspt11"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd11"
echo ""
echo -e "Passing Date & Time -> $isspt22"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd22"
echo ""
echo -e "Passing Date & Time -> $isspt33"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd33"
echo ""
echo -e "Passing Date & Time -> $isspt44"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd44"
echo ""
echo -e "Passing Date & Time -> $isspt55"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd55"
echo ""
echo -e "Passing Date & Time -> $isspt66"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd66"
echo ""
echo -e "Passing Date & Time -> $isspt77"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd77"
echo ""
echo -e "Passing Date & Time -> $isspt88"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd88"
echo ""
echo -e "Passing Date & Time -> $isspt99"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd99"
echo ""
echo -e "Passing Date & Time -> $isspt100"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd100"
echo ""
echo ""

if [[ -z "$astrock" ]]; then

astrop=$(cat /tmp/astros.json | jq -r '.people[] | .name')
astroc=$(cat /tmp/astros.json | jq -r '.people[] | .craft')
astropc=$(paste <(echo "$astrop") <(echo "$astroc"))
astropn=$(cat /tmp/astros.json | jq -r '.number')

echo -e "Do you know there are $astropn humans in space currently!"
echo -e "Here are the names of astronauts & spacecraft they are on,"
echo ""
echo -e "$astropc" | sed -e "s/[[:space:]]\+/ /g"
echo ""
else
echo ""
fi

rm /tmp/issn.json
rm /tmp/issp.json
rm /tmp/astros.json
rm /tmp/gcd.json
exit 0



Save the script 'iss' somewhere in your $PATH and 'chmod 755' it. You need to add values to a few variables in the script before using it. First variable is 'latit'. Assign the latitude of your location to it. The second variable is 'longi'. Assign the longitude of your location to it, Last variable is 'eleva'. Assign the elevation (in meters) of your location to it. Save the changes. Where do you get the latitude-longitude-elevation for your place? Easy! Just go to the following website and search for the laitude-longitude-elevation of your location,

HeavensAbove - Location selector

Type 'iss' in your terminal, hit enter and have sum astronomical fun!
Looking forward to your feedback on this script.
Cheers!!!
You Can't Always Git What You Want

dizzie

Reclaim your culture, it's within your reach!

My Blog | Facebook | Twitter | G+ | VSIDO |