InstantTrack Tutorial:
Automatic Keps Downloading using cURL

InstantTrack provides a mechanism that makes it easy to let another program update the Keplerian elements database maintained by InstantTrack. This tutorial shows you exactly how to set this up using cURL to download elements from the AMSAT.ORG web site.

1. Set Up cURL

cURL is a command-line program that can fetch from the Internet nearly any file that a web browser can, given just its URL (that is, its web address). cURL is available from http://curl.haxx.se/ for Windows (95, 98, ME, NT, 2000, or XP, but not 3.1) and for many other operating systems. Go to the download page and get the version you need. Assuming you're running Windows, get the Win32 version without SSL support (for simplicity). Either way, you'll download a zip file. When you open the zip file (using WinZip or whatever you usually use) you'll find a single executable, and some auxiliary files you won't need. Just extract the CURL.EXE file into your InstantTrack directory (usually, that's C:\IT).

Here's a local copy of cURL 7.9.7 for Windows (no SSL) in case you have trouble getting it from the cURL site. This may not be the latest or best version of cURL.

If you're running plain MS-DOS, there is even a version of cURL for you. It does require some additional components. If you have trouble with that solution, try the WATTCP tutorial instead.

2. Create a Batch File

You'll need to create a batch file to take care of some of the details of the automatic update. Use a text editor (such as Notepad) and type in the following:

@echo off
c:
cd \it
copy it.orb itorb.bak
curl http://www.amsat.org/amsat/ftp/keps/current/nasa.all >nasa.all
it /f nasa.all

Save the file with a suitable name, such as GETKEPS.BAT (it must end with .BAT), in your InstantTrack directory. Or, to save the step of building the file, just download my GETKEPS.BAT and save it in your InstantTrack directory.

I've assumed that your InstantTrack directory is C:\IT. If you have installed InstantTrack elsewhere you'll need to change lines 2 and 3 to reflect the correct drive and directory.

If you're interested in the technical details, see this explanation of the batch file.

The Backup File

The batch file we used also creates a backup copy of the database in ITORB.BAK. This can rescue you from ONE bad update. To restore the database to the way it was before the update, delete the file IT.ORB and rename ITORB.BAK to IT.ORB. Note that this will also eliminate any manual changes you have made since the update.

If you don't need a backup file, you can delete the copy command from the batch file.

3. Run the Batch File Manually

You'll need to be connected to the Internet for this to work. If you're lucky enough to have an always-on connection (cable modem, DSL, satellite, etc.) you won't need to worry about this. If you dial up using a modem, you can either do so manually before running the batch file, or (I think) you can configure Dialup Networking to dial automatically whenever a program tries to access the Internet.

You can run the program from the command line, if you like. Just CD to the InstantTrack directory and type the name of the batch file, GETKEPS. The program will quickly download the NASA-format elements file and feed it to InstantTrack. If you have a fast connection and a fast computer, this will all happen so fast it seems, well, Instant. Even on a dialup, it shouldn't take more than a few seconds, unless it has to dial the modem.

If you expect to run the update manually, you will probably want to create a shortcut. Open the Windows Explorer and navigate to the InstantTrack directory, C:\IT. Right-click on the batch file (it may look like GETKEPS or like GETKEPS.BAT, depending on how you have Windows Explorer set up). Choose Create Shortcut and let it create a shortcut for you. Find the shortcut at the bottom of the files. It will be named Shortcut to GETKEPS.BAT. Right-click on it, choose Rename and give it a better name, such as Get Keps. Right-click on it again, choose Properties, choose the Program tab, and check the Close on exit box. Now drag the renamed shortcut onto the desktop. You can run it from there, anytime, by just double-clicking the icon.

If you prefer a clean desktop, move the icon into your Start menu.

Try it now. Did it work? Check for a NASA.ALL file on your disk with today's date. If there's a problem with cURL, that file won't show up. In that case, add a PAUSE command after the CURL command in the batch file, and try again. This will give you a chance to see whatever error message cURL is reporting.

Note: the IT.ORB file will be updated only if there are newer elements in the downloaded file. Don't let this confuse you when testing out your batch file. The date and time on the IT.ORB file won't change every time you run the batch file. You can force it to change by running InstantTrack and deleting the elements for one of the satellites in the downloaded set. That way, the automatic update will need to re-add that satellite, forcing it to update the IT.ORB file.

4. Run the Batch File Automatically (Optional)

The elements on AMSAT.ORG are updated once a week. There's no need to download it more often than that. Wouldn't it be nice if that could just happen automatically without you doing anything? Here's how.

Windows 2000: From the Start menu, choose Settings, then Control Panel.

Windows 98SE: Double-click on My Computer.

Windows (others): find Scheduled Tasks wherever they've hidden it this time.

Double-click on Scheduled Tasks. Double-click on Add Scheduled Task. Click Next> to begin the wizard. Your batch file isn't an application that Windows knows about, so click Browse, navigate to C:\IT, and double-click on the batch file. Choose Weekly and enter a suitable name, such as Update Keps using cURL. Click Next> again, and choose your time. It doesn't matter when during the week you choose, as long as your computer is switched on and has Internet access at the time you choose. Choose only one day of the week, and Every 1 weeks. Complete the rest of the wizard until it lets you click Finish.

That's it! You should never have to worry about loading new Keps 


Last updated 04 December 2003. Comments to KB5MU, kb5mu@amsat.org

Copyright 2002 Paul Williamson. All Rights Reserved.