Home page of Eric Pement

Home > tcmd.htm


Take Command (also 4DOS and 4NT)

On my computer, I prefer to work from the command line. Though I am comfortable with a mouse and a graphical user interface (or GUI), for many things the keyboard is just much faster.

Not long after I got my first MS-DOS computer, I ran across "4DOS", a replacement for the DOS command line with many additional variables, options, and features. It was a superset of the MS-DOS command interpreter (then, "command.com"): it had all the commands and features of MS-DOS, plus many more. 4DOS, created by JP Software, was terrific for writing batch files. Old-timers who used Norton Utilities may have known it as NDOS, which was really 4DOS rebranded for Norton.

As MS-DOS matured, it developed into Microsoft Windows (with a 16-bit operating system), then Windows NT (with a 32-bit operating system), and other versions (e.g., Windows 95, 98, 2000, etc.). So the 32-bit "CMD.EXE" was unveiled to replace the older "COMMAND.COM". CMD had more flexibility than COMMAND.COM, though it has been enhanced across the years (Windows XP, Windows 7, Windows 8, etc.).

Soon after Windows NT came out, JP Software released 4NT.EXE, a replacement for CMD.EXE. Then they looked for a better way to integrate the GUI features familiar to Windows users (navigation tree, tiled windows, drag-and-drop, etc.) with their command-line shell, 4NT.

What's a shell, you ask? A shell is a hard covering that protects the kernel or sealife inside. In computer lingo, a shell is the "user interface" that lets you send keyboard command and mouse movements to the kernel, which you can never see. You only see the shell. Some shells look and feel different than others, but all of them offer a way to move around the computer, accessing its memory, environment, etc. Shells can be text-mode interfaces, like COMMAND, CMD, 4DOS, Bourne shell, Korn shell (ksh), etc. Shells can also be graphical interfaces to "desktop environments," such as Microsoft Windows, the Macintosh Finder, KDE, GNOME, etc.

JP Software developed a new shell, "Take Command", a powerful work environment that includes both the text-mode interface, TCC, and an Explorer-like graphical interface with tabs, dockable windows, and much more. It is not a replacement for all of Windows, but it does provide a rich avenue to "doing things" for users who need more than CMD has to offer, but something less intimidating than PowerShell.

The new Take Command retained nearly all the options, variables, and syntax introduced in 4DOS and 4NT. So when you see references to 4DOS or 4NT in this section, remember that scripts that run under 4DOS or 4NT will almost always will run unmodified under TCC and Take Command.

Things I wrote for TCC (or 4DOS, 4NT, etc.)

  • getopts121.zip - Of all the things I've written for 4DOS/Take Command, I consider this the most important and most useful for batch scripting. Details below:
     getopts is a batch file that enables case-sensitive switch parsing under Take
     Command and its predecessors (4DOS, 4NT, TCC), in a manner identical to the
     behavior of getopts under Unix.
       * Position-independent switch clustering
           "-a -b -c" equals "-ac -b" equals "-c -ba" equals "-bac".
       * 3 types of switches:
           Character switches, String switches, and Numeric options.
       * Case-sensitive character switches
           Character switches are one character (a-z or A-Z); they NEVER
           take an argument or parameter. They are case-sensitive, meaning
           that "-d" and "-D" are seen as different switches.
       * Case-sensitive string switches
           String switches are one character (a-z or A-Z); they MUST take
           an argument or parameter. Thus, -f and -F are DIFFERENT switches
           whose arguments can be passed as '-fhello' or '-F goodbye'.
           Multi-word arguments are permitted if they are enclosed in double
           quotes, such as '-g "one or more words"'.
       * Numeric options
           Numeric options may be permitted or forbidden. If permitted,
           -123 will set N=123, and --456 will set N=-456.
       * Switches and argument removed from the command tail
           Under GETOPTS, all switches and switch parameters on the command
           line are placed into appropriate environment variables. The
           switches are then removed from the command tail. If the batch
           file executes any external utilities, the utility's own option
           syntax can be used (e.g., /opt1, opt2:opt3, word=opt4, etc.).
       * Halt on invalid options
           The parent batch file contains a list of permissible letters for
           character and string options, and tells whether numeric options
           are allowed. The GETOPTS batch file first checks the list itself
           and then checks each option on the command tail for validity.
           GETOPTS will halt if it detects invalid options, but it can be
           set to "pass" invalid options through instead.
       * Switch termination
           To permit processing filenames which begin with leading
           hyphens, the switch "--" terminates switch processing, and the
           rest of the command tail is returned untouched to the parent
           batch file. Further, a single hyphen "-" by itself is passed
           without modification to the command tail.
     If getopts.btm is present on the PATH, just a few lines need to be added to
     your batch file to enable this position-independent parsing. Note that several
     of the scripts below require getopts to work.

  • archives
    $ archives --help
    Usage: archives [d:\dir]
    Simple "dir" selector to display various archive
    forms in specified orcurent directory. Archive types:
      arc, arj, lbr, lzh, zip, zoo, 7z, bz2, xz

  • commify.zip
    $ commify --help
    Usage: commify [-options] [file1 file2 ...]
    Add commas to sequences of 4 consecutive integers, but only to the
    non-decimal portion of a string of numbers
      -?  Display this help message
      -h  Display this help message
      -d  In the decimal portion, insert an underscore after every 3 digits

  • areacode.zip - basic search for area codes:
    $ areacode --help
    AREACODE - Show North American area codes
    At least 1 argument required (Default: case-insensitive regex match)
    Usage: areacode [-options] {number|city|state-abbrev}
      -i    case-sensitive and \<whole-word\> search
      -?    display this help message
    Sample usage:
      areacode 773      - displays area code for Chicago
      areacode boston   - displays area code for Boston
      areacode VT       - displays area code for Vermont
      areacode "\<51"   - display all area codes beginning with '51'
    Phone areacode db last updated on 2011-08-10
    Latest versions are at http://savannah.gnu.org/projects/miscfiles/

  • diacriticals - a very simple batch file that only shows help and nothing more. This file is matched to Code Page 457 (OEM codepage), but will look wrong if viewed with CP1252 (Windows-ANSI codepage) or in a browser.
    $ diacriticals
    @echo off
    Dec  Ch  Words containing diacritical characters                    HTML char
    ===  ==  =======================================                    =========
    129  ü   Düsseldorf, Tübingen, Der Führer, gemütlich, natürlich      &uuml;
    130  é   attaché, blasé, bon appétit, cliché, communiqué, détente,   &eacute;
             décolleté, entrée, exposé, fiancé (m), fiancée (f), née,
             outré, passé, protégé, résumé, risqué, touché, vive la différence
    131  â   château, coup de grâce, papier-mâché                        &acirc;
    132  ä   doppelgänger, fräulein                                      &auml;
    133  à   déjà vu, vis-à-vis, à la carte, à la mode, voilà!           &agrave;
    134  å   ångström                                                    &aring;
    135  ç   façade, garçon, Provençal                                   &ccedil;
    136  ê   tête-à-tête, bête noire, raison d'être                      &ecirc;
    137  ë   Noël                                                        &euml;
    138  è   pièce de résistance, cause célèbre, père                    &egrave;
    139  ï   naïve, naïveté, opïum                                       &iuml;
    143  Å   Århus (or Aarhus), Dk; Å (angstrom, 0.1 nanometers)         &Aring;
    147  ô   table d'hôte                                                &ocirc;
    148  ö   Möbius strip, Köln, schöne, Bön                             &ouml;
    154  Ü   "Deutschland Über Alles"                                    &Uuml;
    160  á   The Báb, Bahá'u'lláh, Galápagos Islands, Juáraz             &aacute;
    161  í   Aída, Mírzá Husayn-Alí, Bahá'í                              &iacute;
    164  ñ   señor, señorita, mañana, piñata                             &ntilde;
    168  ¿   ¿Qué pasa, amigo?                                           &iquest;
    See also http://en.wikipedia.org/wiki/List_of_English_words_with_diacritics
  • minit - I didn't like the help menu that came with "mtr" ("minitrue"), so I entirely rewrote it
    $ minit --help
    minit.btm (wrapper for mtr.exe) - USAGE SUMMARY
    as a file pager:
      mtr  file1 file2... - "regex"       # pattern to locate
    as a grep search tool:
      mtr -ro# afn1 - "reg.exp"          # -Recurse, number lines to stdout
    as a replacement tool:
      mtr afn1 afn2... - "find" = "repl"  # prompted replace in pager
      mtr -nr afn1 ... - "find" = "repl"  # -No prompt, -Recurse, change files
      mtr -no+ file1   - "find" = "repl"  # -o+ = send results to stdout (sed)
     -a  All files       -w  Whole words only        -r  Recurse dirs
     -c  case ignore     -y  skip bin files          -tTABSIZE set Tab size
     -e  ignore errors   -@:FILE input filename      -v  set Video mode
     -h  hex mode        -b  make Backups            -x  use regexes
     -k  keep stats      -d  keep prev Datestamps    -z  unZip files
     -mNUM  top Margin   -f  Fold lines @ wd breaks  -u  boolean zone
     -o  use stdout      -i:FILE input strings file  -p:SET define printing chars
     -q  quiet mode      -l  make Log file
     -s  fast Scroll     -n  No prompting            -? (tutorial) or --help
      -c  Case-insensitive matching ON (use -c- to disable)
      -x  Regex matching ON (use -x- to disable)
      -b  Numbered backups ON (use -b- to disable)
      Env var MINITRUE="-p:[\x00-\x08\x11\x12\x14-\xFF] -v:blwh:Grye:GrBl:blgr"
    Escape chars are always active, even if regexes are disabled with -x- :
      \a  BEL  ^G   |  \n  NL   ^J    |  \xHH  hex value, 0xHH
      \e  ESC  ^[   |  \r  CR   ^M    |  \NNN  octal value (also \N and \NN)
      \f  FF   ^L   |  \t  TAB  ^I    |    \b  If -x, wordbreak. Use [\b] for BS
      \z  nil ("")  |  \\  backslash  |    \b  If -x-, backspace  ^H.

  • nonasc.btm.txt - Shows whether a file is pure ASCII or not. Requires od (octal dump) and sed.
    $ nonasc --help
    NONASC.BTM v1.43 -
      Look for non-printable chars in file or input. Valid chars include 20h-7E,
      TAB, CR, and LF. Control codes or graphic chars are considered "non-ASCII".
      The input file is not changed. Exit code 0 if pure ASCII, or 1 otherwise.
    Usage: nonasc [-options] [filename]
      Only 1 filename allowed. If filename is omitted, read from stdin. If no
      switches are used, look for non-printing characters and display the first
      2 lines of non-printing chars, if any. Hits are shown in reverse video.
      -d    Dump the input file in both hex and ASCII to the screen without
            checking for invalid characters. Works on pure binary files.
            Long files should be piped through a file pager (e.g., "less").
            If the -{n} switch is used, limit the output to {n} lines.
      -{n}  Display {n} lines of input, where {n} is an integer (default: 2)
            If -d is omitted, display {n} lines of invalid input.
            If -d is used, display {n} lines beginning at top of file.
            Numeric switch must be separate from other options! Thus,
            "-d -5" and "-7 -t" are valid, but "-d5" or "-7t" are not.
      -t    Include TAB (0x09) as invalid char.  -t and -d are incompatible.
            If both are present, -t will be ignored.
      -r    Include CR (0x0D) as invalid char.
      -z    Allow Ctrl-Z (0x0A), but only at EOF.
      -?, --help      Display this help message

  • rot13.btm.txt - Basic filter:
    $ rot13 --help
    ROT13 - simple Caesar cipher for reversible obfuscation. ROT13
    affects alphabetic characters only (A-Z and a-z), nothing else.
    Usage: rot13 [file]
      {cat|type|echo|etc.} filename | rot13   # use as a filter
      rot13 filename                          # use with one argument
      rot13 /?, /h, -?, --help                # brings up this help message

  • rot47.btm.txt - Basic text filter:
    $ rot47 --help
    ROT47 - simple Caesar cipher with a larger alphabet than ROT13.
    ROT13 affects alphabetic characters only. ROT47 affects all 94
    printable characters: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ and the
    62-character set [0-9A-Za-z]. Literal cmd:  tr '!-~' 'P-~!-O'
    Usage: rot47 [file]
      {cat|type|echo|etc.} filename | rot47   # use as a filter
      rot47 filename                          # use with one argument
      rot47 /?, /h, -?, --help                # brings up this help message

  • unixtime.btm.txt - Converts to and from Unix "epoch seconds" (requires Unix "date")
    $ unixtime --help
    UNIXTIME - displays specified time in epoch seconds (ESEC), and also
    converts time from epoch seconds (since 1970-01-01 00:00:00 UTC)
      unixtime                             Show ESEC for current date/time
      unixtime [-c] [YYYY-MM-DD HH:MM:SS]  Show ESEC for specified date/time
      unixtime -s ESEC                     Given epoch seconds, show the ISO time
      -c            Add commas (when displaying epoch seconds)
      -s 1234567    Convert epoch seconds to ISO time
    Similar commands:
      perl -e "print scalar time"          # show current time in epoch seconds
      date +%s                             # show current time in epoch seconds
      echo %@eval[%@makeage[%_utcdate %_utctime] \ 10000000 - 11644473600]   # TCC
      date -d "YYYY-MM-DD HH:MM:SS" +%s    # show given date/time in epoch seconds
      date --date="now|1/23/2008" +FORMAT  # show given date/time in another format
      date --date="@1234567" +"%F %T %Z"   # convert epoch seconds to ISO format

  • unwrap.btm.txt - simple:
    $ unwrap --help
    UNWRAP.btm - TakeCommand script to "unwrap" lines from stdin or a file.
    Given 2 consecutive lines, if line #2 begins with N spaces (default 4),
    append line #2 to the end of line #1 and remove the spaces.
    Usage: unwrap [-switches] [file1 file2 ...]
     -N   must be a positive integer (default = 4)
     -s   string of 1 or more chars at beginning of line (default = space)
          Note that 's' will be multiplied by 'N', so to wrap 9 tildes at BOL,
          enter `-9 -s~`, or  `-3 -s "~~~"`, or `-1 -s "~~~~~~~~~" `.

  • whatruns.btm.txt - Shows executable files in the specified directory:
    $ whatruns --help
    Usage: whatruns [directory] [/TakeCommand options]
    WHATRUNS accepts directory names and options appropriate for DIR. It
    displays a list of executable files, matching any of these filetypes:
      bat,cmd,btm       DOS batch files, TakeCommand/JPSoft batch file
      com,exe           binary executables
      pl,awk,py         perl, awk, python scripts
      sh,ksh            Bourne shell script, Korn shell script
      ade,adp           Microsoft Access Database (extension, project)
      cpl               Control Panel Extension
      hta               Hypertext Application
      ins,isp           IIS Network Settings script, IIS Service Provider script
      jse               JScript Encoded script
      msc,msi,msp,mst   Microsoft (CommonConsole,installer,patch,visual Test)
      scr,sct           Windows Screen Saver, Windows Script Component
      vb,vbe,vbs        Visual Basic (encoded, script)
      wsc,wsf,wsh       Windows Scripting (component, file, host)
    Default executable extensions are defined by the environment variable %PATHEXT%.
    The following exectuable extensions are automatically BLOCKED by gmail.com,
    and may not be sent, even in an archive (.zip, .tar, .tgz, .taz, .z, .gz):
       "ade", "adp", "bat", "chm", "cmd", "com", "cpl", "exe",
       "hta", "ins", "isp", "jse", "lib", "mde", "msc", "msp",
       "mst", "pif", "scr", "sct", "shb", "sys", "vb",  "vbe",
       "vbs", "vxd", "wsc", "wsf", "wsh"

These pages created with GNU Emacs, xhtmlpp, Take Command, and Altap Salamander. Icons courtesy of Qbullets
Last modified: 2015-01-17