[amsat-bb] Re: Unix command line Kepler manager

Gus 8p6sm at anjo.com
Wed Mar 13 23:15:39 PDT 2013


Here is a bash script that might be of help:

--------8<--------
#!/bin/bash

CAT=/usr/bin/cat
RM=/usr/bin/rm
WGET=/usr/bin/wget
GREP=/usr/bin/grep

VERBOSE=1

# change these to suit your taste
OUTPUT=${HOME}/MySatellites.tle
MATCH=${HOME}/Sats_I_Like.txt

# delete existing output file
if [ -f ${OUTPUT} ]; then
   [[ $%{VERBOSE} ]] && echo "Deleting ${OUTPUT}"
   ${RM} ${OUTPUT};
fi

# heredoc contains URLs of interest.  Edit to suit yourself
[[ $%{VERBOSE} ]] && echo "Fetching elements from www.celestrack.com"
${CAT} << EOF | while read URL
http://www.celestrak.com/NORAD/elements/amateur.txt
http://www.celestrak.com/NORAD/elements/weather.txt
http://www.celestrak.com/NORAD/elements/visual.txt
EOF
do
   [[ $%{VERBOSE} ]] && echo "-- ${URL}"

   ${WGET} -q ${URL} -O - | ${GREP} -A 2 -f ${MATCH} >> ${OUTPUT}
done

[[ $%{VERBOSE} ]] && echo "Done."

-------->8--------

This will fetch one or more element files from celestrack (you say which 
URLs to use in the heredoc) and pick out satellites of interest to you 
by name, combining the results into a single output file.  You specify 
the satellites you want in a match-file (name defined at the top of the 
script) and similarly the name of the file where you want the results put.

Two cautions:  1) be careful with your matches.  "AO-7" matches with 
"AO-71" too.  And 2) if a satellite appears in more than one input file, 
it will appear more than once in the output.  (Example, ISS (ZARYA) 
appears in amateur.txt and visual.txt.)

You could change a few things -- select by satellite number & designator 
rather than name, for instance, or read URLs from an external file. Or 
have the heredoc also specify the name of the output file for each input 
URL.  But for anything much fancier than this (like sorting the output 
by satellite name, skipping duplicates, anything but the simplest of 
command-line arguments, etc)  I'd go with a perl script.

On 03/13/2013 03:00 AM, PE0SAT | Amateur Radio wrote:
> Hi Gus,
>
> As I mentioned "I thought to give the list a try before if go the 
> script way"
>
> Do you have such a script?
>
> Make an input variable with the desired SATS read from input files and 
> output to
> my own output file that I can use with my favorite tracking software.
>
>
> 73 Jan PE0SAT
>
> On 12-03-2013 23:22, Gus wrote:
>> What exactly do you need to do?
>>
>> Download the elements from celestrack with wget or Perl's
>> LWP::Simple.  Use grep with the --files option to select satellites of
>> interest and write them out to whatever destination you want. What
>> else do you need?
>>
>> A modest Perl script would go a long way...
>>
>>
>>
>>
>> On 03/12/2013 05:29 PM, PE0SAT | Amateur Radio wrote:
>>> Hi,
>>>
>>> Thanks for reading this message.
>>>
>>> Can somebody help me with a command line Kepler manager for Unix?
>>>
>>> The idea is to create my own TLE files where source files come from 
>>> Celes-track and
>>> Space-track.
>>>
>>> I thought to give the list a try before if go the script way ;)
>>>
>>> 73 Jan PE0SAT
>>>
>

-- 
73, de Gus 8P6SM
Barbados, the easternmost isle.



More information about the AMSAT-BB mailing list