wxrx/update_satellites.sh

30 lines
620 B
Bash
Raw Permalink Normal View History

2022-07-06 16:57:31 -07:00
#!/usr/bin/env bash
2022-01-23 12:40:47 -08:00
## Fetch satellite TLE data
## usage: __PROG__ [<outfile>=satellites.tle]
2022-01-22 15:15:37 -08:00
2022-01-23 12:40:47 -08:00
prog="$0"
2022-02-02 07:27:26 -08:00
me=${HELP:-`basename "$prog"`}
rootdir=$(dirname $(realpath $0))
2022-01-23 12:40:47 -08:00
source ${rootdir}/lib/utils.sh
# Print usage
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
usage
exit;
fi
2022-01-22 15:15:37 -08:00
outfile=${1:-'satellites.tle'}
2022-01-23 12:40:47 -08:00
log "Updating satellite information"
2022-01-22 15:15:37 -08:00
curl -L https://www.celestrak.com/NORAD/elements/weather.txt 2>/dev/null | \
2022-01-22 15:15:37 -08:00
grep 'NOAA 15\|NOAA 18\|NOAA 19' --no-group-separator -A 2 > ${outfile}
2022-01-23 12:40:47 -08:00
if [ $? ]; then
log "Wrote to ${outfile}"
exit
else
err "Unable to fetch satellite information"
exit 1
fi