This document and the ntcli collection of programs and source code are
all Copyright © Tom Horsley, 1998 (unless otherwise noted in the source
files). All rights reserved. The right to unlimited not for profit
distribution and use of these programs is granted to anyone who agrees to keep
the copyright notice intact and not alter the programs. (In other words,
if you want to make money off of these, I want some of it too :-).
It should also be noted that the word Unix which is used in
various places is copyrighted by someone, but I'm darned if I can keep
track of who these days (AT&T?, SCO?, HP?, Unix International?, X/Open?,
someone like that...).
Introduction
The ntcli
tool set is a random collection of NT command line
tools (hence the name). They are functionally very similar to tools of the
same name under Unix, but have a windows flavor and are built to function in
the windows spirit, giving access to windows features (while trying not to
lose any of the Unix functionality).
By no means all possible Unix tools are available here. Only a handful of
commands are implemented (see Commands). Mostly they
are commands I can't live without, or commands I happened to need while
trying to get some makefile to work. No attempt has been made to be logical
about the selection of commands.
Wildcards
All of these commands share the same command line processing which
implements wildcard processing much as the Unix shell does, but with
extra DOS-like features (such as being able to use wildcards in the
device letter position of names). The possible wildcard features
are the *
character which matches any string of characters,
the ?
which matches any single character, and the
[]
character class construct which matches any character
in the set of characters listed inside the []
characters.
If the first character inside a character class is !
, then
the class matches all characters except the ones listed. Ranges of
characters may be specified with a -
(hyphen) separating the two
characters which define either end of the range.
Some examples:
[c-z]:[!0-9]*.c
matches any files with the .c
suffix which do not begin with a digit on any disks from c:
through z:
.
*
matches any files in current directory (unlike
DOS in which you would need to write *.*
).
c:\*\include\*.h
matches any files with the .h
suffix in directories named include
directly underneath
any directory on disk c:
Registry
In addition to sharing common wildcard processing, the commands also
share common processing of registry information which may be used to
install default options for the commands. Every command determines
the name it was invoked with, then looks in the registry under the
key:
HKEY_CURRENT_USER\Software\NTCLI\
progname\1.0
for option settings specific to that program (you can copy the programs to
different names and give them different default behaviors based on the
name). The string progname in this key is the base name of the
program minus the .exe
suffix.
It will also consult the key:
HKEY_CURRENT_USER\Software\NTCLI\Global Defaults\1.0
for option
settings which are common to all the ntcli
programs.
The following DWORD
values may be set to either 1 or 0
(meaning on or off) in either of the keys:
AllowForwardSlash
Set to 1 to allow the forward slash
character to be treated as a directory separator as well as the backslash
character. Set to 0 if only backslash should be allowed. The default
for this value is 1 if not specified in registry.
SeeHiddenFiles
Set to 1 to allow hidden files to be visible
to wildcard expansion. Set to 0 to allow them to remain hidden. The
default for this value is 0 if not specified in registry.
CaseSensitiveWildcards
Set to 1 to make wildcard expansion
case sensitive. Set to 0 to make it insensitive to case. The default
for this value is 0 if not specified in registry.
In addition to those values, the program specific key may also contain a
multi-string value named Options
. These will be added to the
beginning of the command line options so the program always looks as though
it were invoked with those options.
No automatic setup program is available for these keys. You need to use
the registry editor to define them if you want to change the defaults.
Commands
The five commands defined so far are:
basename
Just like the Unix basename. Strips off the leading directory components of
a filename passed as an argument. If two arguments are given interprets the
2nd as a suffix and strips that off the end of the basename if it is
present. Prints the resulting name to standard output.
cat
Pretty much like the Unix cat command, but has a couple of extra win32
arguments. Basically it reads all the files listed on the command line
and prints their contents to standard output. The options are:
-u
make output be unbuffered
-s
silently ignore file arguments which don't exist
-v
print escape code for unprintable characters
-t
print escape codes for tabs and form feeds
-e
print a $ at end of each line
-T
read and write all files in text mode
-B
read and write all files in binary mode
cmp
Compares two files byte for byte. The options are:
-l
show long listing of all file differences
-s
be silent and just set exit code to non-zero if the
files do not match
-T
read files in text mode
-B
read files in binary mode
ls
Deviates more from the Unix that any other command because file
permissions simply aren't organized the same way on Windows as on Unix
and it can't really make sense to emulate Unix exactly. There are a lot
of special win32 options as well as a different way to display file
attributes in long listings.
-a
do not hide hidden or system files or the . and ..
directory names
-b
escape unprintable characters to octal
-c
use create time of file for sort and list
-d
show directory names, not directory contents
-h
print help summary
-j
convert names to all lower case for printing and
sorting
-l
use a long listing format
-m
fill width with a comma separated list of entries
-o
show both long and short names of file in -l listing
(for those files which have a short 8.3 alias)
-p
append a character indicating kind of non-executable
file
-q
escape unprintable characters to a question mark
-r
reverse order while sorting
-t
use modification time of file for sort and list
-u
use last access time of file for sort and list
-w
give argument to specify screen width
-x
list across lines rather than down columns
-A
do not list the . and .. entries, but show other hidden
files
-C
list entries by columns
-D
use DOS format for names and show backslash as the
directory separator rather than forward slash
-F
append a character indicating kind of files
-G
turn on display of group information in -l listing
-I
give argument to specify wild card pattern to be
ignored
-H
print help summary
-J
convert names to all upper case for printing and
sorting
-M
use only the short 8.3 format MS-DOS names of files
-N
do not quote entry names
-O
turn on display of owner information in -l listing
-Q
enclose entry names in double quotes
-R
list subdirectories recursively
-S
sort by file size
-U
list entries in unspecified order without any sorting
-X
sort alphabetically by entry extension
-1
list one file per line
When generating the long format listing (using the -l
option),
the normal Unix 9 character permission bits string is printed instead as
a seven character string summarizing the file attributes. In left to right
order the characters are either printed as -
for no attribute,
or:
d
file is a directory
r
file is readonly
x
file is an executable or a directory
h
file is hidden
s
file is a system file
a
file is marked for archiving
t
file is marked as temporary
The executable information is merely a guess based on the file suffix.
At the moment, only the suffixes .exe
, .cmd
,
.bat
, and .com
are considered executable.
The owner and group information (if requested with the -O
or
-G
options) can only be determined for file systems (such as
NTFS) which actually support security information on files.
rm
The rm command is used to remove files. It is very nearly identical to the
Unix version:
-r
recursively delete whole directory trees
-f
do not generate errors about file that could not be
deleted
-i
interactively prompt for the action to take on each
file
-I
pretend rm is running interactively in a console
window
The -I
option was added for use in places such as
an emacs shell window where rm is running with pipes as standard
in and out. Without the -f
option, rm will interactively
prompt to see if you really meant it when you delete a readonly file,
but only if it thinks it is running on a console.
When it does prompt with a yes or no question about deleting a file,
any reply starting with a y
or Y
will cause
it to delete the file (or try to, anyway).
Installing
Nothing special is required to install, just unzip the
ntclibin.zip
archive in some directory and add that directory
to your path. The tools should work under Windows/NT or Windows/95/98.
You can use the registry editor to define any options you want to change
(see Registry). Finally, you might want to
put the ntcli.html
document somewhere you can find it.
The source code is also available in ntclisrc.zip
. If you
are already setup to run Visual C++, you should just be able to unzip the
file and run nmake
. Before you ask, I have no idea if it works
with the Borland compiler or any other compiler.
Deep Thoughts
The world doesn't really need yet another set of Unix on DOS tools,
but at least these work exactly the way I want them to and are reasonably
small.
If you have any comments, bug fixes, etc., you can send them to me at
Tom.Horsley@worldnet.att.net
(but don't expect too much - this is strictly a free time activity for me).
Naturally, the real reason I put these up on my web page is to lure
unsuspecting victims seeking free software to my
home page where they will
read about my political ideas and join in an unstoppable wave of
grass roots action to bring performance based government to the world
(or something like that, anyway).