[teqc] helpful tip of week 1896

Lou Estey lou at unavco.org
Wed May 11 07:29:57 MDT 2016

This week's tip is for those using teqc on Microsoft Windows.

As you all know, teqc is a command line tool.  It was designed, primarily, to run in
UNIX and Linux shells.  Luckily, most of teqc's functionality works "as is" on the
DOS command line (back in circa mid-'90s) and afterward on the DOS emulation 'cmd' window
in Microsoft Windows releases.

This design has permitted others to develop GUIs that then have teqc as the underlying
engine, and thus allowing teqc development to focus on the "nuts and bolts" of GPS/GNSS,
and allows teqc to be readily and easily incorporated into shell scripts. There have been
one or two such internal GUIs using teqc developed here at UNAVCO, but the most recent
GUI is WinTEQC developed by Mark Huber, Army Geospatial Center, U.S Army Corps of Engineers;
see http://teqc.silkwerks.com/

However, there are plenty of specialized actions that can be easily be done with teqc
if you have access to a UNIX/Linux shell environment and are much clumsier if you don't.
A perfect example: finding options when running `teqc +help`.  Even I can't remember
every teqc option, but I know that the ones I want normal users to know about are
output with the '+help' option (which is the same as the '-help' option; more
about this next week).  So, how do I quickly find what I want?

One of the most useful UNIX tools ever written (and readily adapted by Linux when
it came along) is the command `grep`, which stands for "global regular expressions print".
Generally speaking, you want to find a word or phrase or alphanumeric pattern in a file
and `grep` allows you to quickly find all occurrences.  (BTW, `grep` hands-down
is my all-time favorite UNIX command, which I use so often that in my shell I alias
`grep` with just `g`.)  For example, if you want to find all lines that have one or
more occurrences of 'R10' in the qc summary file named temp1310.16S:

grep R10 temp1310.16S

The beauty of almost all UNIX/Linux commands is that they also work with the "standard output",
aka stdout, of another command.  If you don't do anything with stdout, it is merely
displayed on the screen that your shell is running in.  But with UNIX/Linux shells
you can "redirect" that output somewhere else.  If that redirection is to the
"standard input" (aka stdin) of another command, this is called "piping", done
with the '|' shell operator.  (As far as I know, piping was never universally built
into the Windows 'cmd' window.)

So suppose I want to find all occurrences of 'GLONASS' from running `teqc +help`, I can
"pipe" the stdout of `teqc +help` to `grep`:

teqc +help | grep GLONASS

... which outputs to the screen (from `grep` at the end):

         -n_GLONASS #         set maximum expected GLONASS SV slot #, 0 < # <= 64 (default = 24)
         +R                   use all GLONASS SVs (default)
         -R                   don't use any GLONASS SVs
         +R<list>             use only GLONASS SV slot #s in <list>, e.g. 1,3,5-7,11
         -R<list>             don't use GLONASS SV slot #s in <list>, e.g. 1,3,5-7,11
         -glonass_s2fcn str   str = filename of GLONASS SV slot and corresponding frequency channel number pairs
                                where 'list' == system filename(s) ordered GPS[,GLONASS[,SBAS[,Galileo[,Beidou/Compass[,QZSS]]]]]
         +leap[_seconds]      subtract current leap seconds from GLONASS pseudoranges (default)
         -leap[_seconds]      no leap second adjustments to GLONASS pseudoranges
                 -N.corr[_GLO] yr mon day sec  set RINEX GLONASS NAV correction to system time to yr mon day sec
                                            GPS, GLONASS, Galileo, Beidou/Compass, and/or QZSS

(`grep` has a whole bunch of options, such as '-i' to ignore case, or '-v' to
"reverse grep" and show every line which does _not_ have the matching pattern, etc.)

To accomplish the same discovery, a Windows user would probably redirect `teqc +help`
output to a file and then open the file in an text editor and then search on 'GLONASS'
case by case in the file.

Ok, so what is the helpful tip?  The tip is that for Windows users wanting a UNIX/Linux
shell there is at least one tried and true alternative, and, perhaps, for Windows 10 users
a new alternative.

The tried and true: Cygwin. https://www.cygwin.com/  Which is: "a large collection of GNU
and Open Source tools which provide functionality similar to a Linux distribution on Windows."
I know that Cygwin worked well as far back as Windows XP.  (And maybe on even earlier
versions of Windows.)

For Windows 10 users, the new hopeful alternative is bash ("Bourne-again shell", a GNU replacement
for the original UNIX Bourne shell, sh) on Ubuntu; see:

30 Mar 2016 https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows/
  6 Apr 2016 https://blogs.windows.com/windowsexperience/2016/04/06/announcing-windows-10-insider-preview-build-14316/
  7 Apr 2016 http://www.zdnet.com/article/ubuntu-and-bash-arrive-on-windows-10/

This bash/Ubuntu on Windows 10 is reported to support normal UNIX/Linux programs
like `grep`.  Does it support piping?  I don't know, but if you are experimenting
with this, please report back to the teqc list on your experiences.

As long-time members of this list know, I often make use of UNIX/Linux shell
redirection and piping when trying to demonstrate or explain something, so having
as many of these tools available for you Windows users can come in very handy.


p.s. Personally, I use Korn shell (ksh), which I learned almost 30 years ago.
Recalling and editing past commands in ksh is done with `vi` and I don't even
think about the actual process anymore; the actions seem to be processed in my
medulla oblongata.

p.p.s. For any of you _still_ using C-shell (csh), you need to read these:

More information about the teqc mailing list