[comp.os.minix] A help command

johnc@rtmvax.UUCP (John Connin) (07/18/88)

The enclosed "help" command was posted in Comp.sources.misc: Volume 2,
Issue 18, Date: 26 Jan 88 03:55:38 GMT, by Wolf N. Paul ihnp4!killer!wnp.

The only changes I have made in this posting is (1) adding a minor ifdef
to enable compulation under Minix, and (2) enclosing the Minix man_pages
with index markers added (ie # subject) inlieu of the previous helpfile.

This program has an idea fit to Minix at this time -- it is small, well
written and delivers high utility.  More importantly, it complements the
excellent manual pages being produced by AST and Terry Holm (i.e. EFTH
Minix reports) by providing a convenient presentation tool.

Enjoy..  John L. Connin

--- help.man --  

help - Provide brief command explanations [ ] prints out a  quick
explanation of a command.  The provides entries for automatically
installing (and un-installing) this package. You need to be  root
to  install  will  completely install the needed files in the ap-
propriate directories with the needed permissions and  ownership.
will remove the effects of If you have the MKS Toolkit, you could
use their helpfile as a starting point for a UNIX SysV  helpfile.
If  you  don't  have the Toolkit, you can construct a helpfile by
gleaning short command descriptions from your manual, and  adding
them  to  the  helpfile, according the the pattern of the partial
helpfile provided.

    /usr/lib/helpfile  default datafile containing help info

    $HELPDIR       Environment variable - directory for helpfile
    $HELPFILE      Environment variable - alternate name for helpfile

------------- cut here ---------------

echo x - MANIFEST
sed '/^X/s///' > MANIFEST << '/'
X-rw-r--r--  1   root     7199 Jul 17 12:42 help.c
X-rw-rw-rw-  1   root    67269 Jul 17 12:48 help.sh
X-rw-r--r--  1   root    33451 Jul 17 12:39 helpfile
X-rwxr-xr-x  1   root      135 Feb 14 01:13 info
X-rwxr-xr-x  1   root      135 Jul 16 20:16 info.save
X-rw-rw-rw-  1   root      975 Jul 17 12:30 makefile
X-rw-r--r--  1   root     2334 Feb 14 01:14 readme
/
echo x - help.c
sed '/^X/s///' > help.c << '/'
X/*
X * Name:    help.c
X * Purpose: display help about commands & system features
X * Syntax:  help [cmd]
X * Comment: Help displays help screens on all user commands
X *          as set up in the file /usr/lib/helpfile.
X *          It is particularly useful on systems with restricted 
X *          diskspace, where it is not practical to keep the manuals
X *          on-line.
X *          The command is patterned after the MKS Toolkit command
X *          of the same name. If no /usr/lib/helpindex file exists, or if
X *          it is older than the helpfile, a new helpindex will be
X *          created to allow faster access to the helpscreens by
X *          means of fseek().
X *          Desirable enhancements would include the possibility to
X *          have help look in an environment variable HELPFILE for
X *          an alternate or additional helpfile,
X *              [ Done by John Plocher - uses HELPDIR to set the directory
X *              where the help file and its index are.  It also uses HELPFILE
X *              to give the name of the data file ($HELPFILE.idx is the index)
X *              defaults are "/usr/lib" and "helpfile" ]
X *          and/or to have help look in $HOME/.helpfile if a command
X *          is not found in the default helpfile.
X *          Another useful feature would be the possibility of using
X *          a pager specified by $PAGER to output the help info, since
X *          a few entries (stty, vi, ...) are longer than one screen.
X *          No doubt the coding could be considerably improved, and
X *          any suggestions would be more than welcome.
X * Author:  Wolf Paul, ihnp4!killer!dcs!wnp
X * Date:    Dec. 18, 1987
X *
X * Revision Control Information
X *
X * Last edited by: $Author: plocher $
X *         $Revision: 1.1 $
X * Last modified:  $Date: 87/12/26 23:34:50 $
X * Source is in:   $Source: /u/microport/src/help/RCS/help.c,v $
X *
X * Release state:  $State: Posted $
X *
X * Modification Log
X * ----------------
X *
X * $Log:   help.c,v $
X * Revision 1.1  87/12/26  23:34:50  plocher
X * Added enviroment variables for HELPDIR and HELPFILE
X *
X * Revision 1.2  88/07/17  John L. Connin
X * Ported to Minix, ie. see ifdef MINIX 
X */
X
X#ifndef lint
X    static char rcsid[] =
X     "$Header: help.c,v 1.1 87/12/26 23:34:50 plocher Posted $";
X#endif
X
X#define  MINIX
X
X#include <stdio.h>
X#include <ctype.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
X
X#define MAXLINE    134
X#define HELPDIR    "/usr/lib"      /* Added by John Plocher */
X#define HELPFILE   "helpfile"      /* .. */
X#define INDEX      ".idx"          /* .. */
X
Xchar helpfilename[128];    /* John Plocher */
Xchar helpidxname[128];     /* .. */
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X   struct
X   {
X       char name[15];
X       long offset;
X   } entry;                /* helpindex entries for each command */
X
X   struct stat sbuf1, sbuf2;   /* stat buffers for helpfile & helpindex */
X   char *command, *line, Line[MAXLINE];
X   register char   *cp;        /* John Plocher */
X   extern char *getenv();      /* .. */
X   int status;
X   FILE *ifp, *hfp;        /* file pointers for helpfile and helpindex */
X   
X   if ( argc == 1 )        /* If no arguments, ... */
X       command = "help";   /* ... default to "help help" */
X   else
X       command = argv[1];  /* else look for command in argv[1] */
X
X
X   /*      Added by John Plocher Sat Dec 26 22:02:09 CST 1987
X    * Look for:
X    *  getenv("HELPDIR") + getenv("HELPFILE")
X    *  getenv("HELPDIR") + "helpfile"
X    *  "/usr/lib"        + getenv("HELPFILE")
X    *  "/usr/lib"        + "helpfile"
X    */
X   if ((cp = getenv("HELPDIR")) != NULL)   /* if a dir is given, use it */
X       strcpy(helpidxname, cp);
X   else
X       strcpy(helpidxname, HELPDIR);
X   strcpy(helpfilename, helpidxname);
X   strcat(helpfilename, "/");
X
X   if ((cp = getenv("HELPFILE")) != NULL)  /* if a filename is given, use it */
X       strcat(helpfilename, cp);
X   else
X       strcat(helpfilename, HELPFILE);
X
X   strcpy(helpidxname, helpfilename);      /* make a name for the index file */
X   strcat(helpidxname, INDEX);
X
X   stat(helpfilename, &sbuf1); /* get mtime for helpfile */
X   status=access(helpidxname, 0);
X   if ( status == 0 )  /* if helpindex exists ... */
X   {
X       stat(helpidxname, &sbuf2);  /* get mtime for helpindex */
X   }
X   if ( (status != 0) ||           /* if there is no helpindex ... */
X#ifdef MINIX
X       (sbuf1.st_mtime > sbuf2.st_mtime) )
X#else
X       ((time_t)sbuf1.st_mtime > (time_t)sbuf2.st_mtime) )
X#endif
X                                   /* or if it is older than helpfile */
X   {
X       buildindex();       /* build a new helpindex */
X   }
X
X   if ( (ifp=fopen(helpidxname, "r")) == NULL )
X   {
X       fprintf(stderr, "Can't read %s\n", helpidxname);
X       exit(-1);
X   }
X   
X   while ( 1 )     /* look for index entry for "command" */
X   {
X       status=fread(&entry, sizeof(entry), 1, ifp);
X       if ( status==0 ) /* quit at end of index file */
X       {
X           fprintf(stderr, "No help for %s\n", command);
X           fclose(ifp);
X           exit(1);        }
X       if ( strcmp(entry.name, command) == 0 ) /* quit when we find it */
X       {
X           fclose(ifp);
X           break;
X       }
X   }
X
X   if ((hfp=fopen(helpfilename, "r")) == NULL )
X   {
X       fprintf(stderr, "Can't open %s\n", helpfilename);
X       exit(-1);
X   }
X
X   fseek(hfp, entry.offset, 0);    /* go to the help entry */
X
X   while ( 1 )         /* just copy lines to stdout */
X   {
X       line = fgets(Line, MAXLINE, hfp);
X       if ( line == (char *) NULL || line[0] == '#' )
X                       /* until another entry starts */
X           break;
X       fputs(line,stdout);
X   }
X
X   fclose(hfp);
X}
X
Xbuildindex()
X{
X   FILE *hfp, *ifp;
X   struct {
X       char name[15];
X       long offset;
X   } entry;
X   char Line[MAXLINE];
X   char *line;
X   int i,j;
X
X
X   unlink(helpidxname); /* remove old index file */
X   if ( (hfp=fopen(helpfilename, "r")) == NULL )
X   {
X       fprintf(stderr,"buildindex: Can't read %s\n", helpfilename);
X       exit(-1);
X   }
X   if ( (ifp=fopen(helpidxname, "w")) == NULL )
X   {
X       fprintf(stderr, "buildindex: Can't write %s\n", helpidxname);
X       exit(-1);
X   }
X
X   while (1)   /* Read thru helpfile ... */
X   {
X       entry.offset=(long) 0;
X       line = fgets(Line, MAXLINE, hfp);
X       if ( line == (char *) NULL ) break;
X       if ( line[0] == '#' )   /* and for each help entry ... */
X       {
X           line++;
X           while ( isspace(line[0]) ) line++;
X           i=j=0;
X           while ( line[i] != '\0' )
X           {
X               if ( line[i] == '\n' ) break;
X               while ( line[i] == ' ' || line[i] == ',' ) i++;
X               while ( !isspace(line[i] ) &&
X                       line[i] != ',') /* save its name ... */
X               {
X                   entry.name[j] = line[i];
X                   i++; j++;
X               }
X               while ( j < 15 )
X                   entry.name[j++] = '\0';
X               j = 0;
X               entry.offset=ftell(hfp);    /* and its offset ... */
X               fwrite(&entry, sizeof(entry), 1, ifp);
X                                       /* and write it to indexfile */
X           }
X       }
X   }
X   fclose(hfp);
X   fclose(ifp);
X}
/
echo x - helpfile
sed '/^X/s///' > helpfile << '/'
X# version
X
Xhelpfile v1.3b  July 17, 1988
X
X# ar
X
XCommand:	ar - archiver
XSyntax:		ar [qrxdpmt][abivulc] [posname] archive file ...
XFlags:		(none)
XExamples:	ar r libc.a sort.s	# replace sort.s in libc.a
X		ar rb a.s libc.a b.s	# insert b.s before a.s in libc.a
X
X     Ar allows groups of files to be put together into a single archive.
XIt is normally used for libraries of compiled procedures.  The following keys
Xare allowed:
X	  q: quickly append to the end of the archive file.
X	  m: move named files. Ar expects 'a', 'b', or 'i' to be specified.
X	  r: replace (append when not in archive).
X	  d: delete. Ar will delete the name members.
X	  t: print the archive's table of contents.
X	  p: print the named files (list them on standard output)
X	  x: extract
X
XThe keys may optionally concatencated with one or more of the following:
X	  l: local temporary file for work instead of /tmp/ar.$$$$$
X	  v: verbose
X	  a: after 'posname'
X	  b: before 'posname'
X	  i: before 'posname'
X	  c: create  (suppresses creation message)
X	  u: replace only if dated later than member in archive
X
X# ascii
X
XCommand:	ascii - strip all the pure ASCII lines from a file
XSyntax:		ascii [-n] [file]
XFlags:		-n Extract the lines containing nonASCII characters
XExamples:	ascii file >outf	# put all the ASCII lines on outf
X		ascii -n <file >outf	# write nonASCII lines to outf
X
X     Sometimes a file contains some nonASCII characters that are in the way.
XThis program allows the lines containing only ASCII characters to be grepped
Xfrom the file.  With the -n flag, the nonASCII lines are grepped.  No matter
Xwhether the flag is used or not, the program returns an exit status of true
Xif the file is pure ASCII, and false otherwise.
X
X# ast
X
XCommand:	ast - add symbol table to executable file
XSyntax:		ast -xX [file] [symbol_file]
XFlags:		-x do not preserve local symbols
X		-X preserve local symbols (except compiler generated ones)
XExample:	ast -X a.out		# add symbols from symbol.out to a.out
X
X    Ast adds the symbol table produced by the -s option of asld to the 
Xexecutable file.  If no symbol table file is listed, the default name 
X'symbol.out' is used.  The symbol table can be generated by the command
Xcc -s file.c >symbol.out.
X
X# at
X
XCommand:	at - execute commands at a later time
XSyntax:		at time [month day] [file]
XFlags:		(none)
XExamples:	at 2315 Jan 31 myfile	# myfile executed Jan 31 at 11:15 pm
X		at 0900			# job input read from stdin
X		at 0711 4 29 		# read from stdin, exec on April 29
X
X     At prepares a file to be executed later at the specified time by creating
Xa special entry in /usr/spool/at.  The program atrun should be started 
Xperiodically, for example, every minute by cron.  Atrun checks to see if any
Xfiles in /usr/spool/at should now be run, and if so, it runs them and then puts
Xthem in /usr/spool/at/past.  The name of the file created in /usr/spool/at by 
Xat is YY.DDD.HHMM.UU (where YY, DDD, HH, and MM give the time to execute and 
XUU is a unique number).  Note that when the command runs, it will not be able 
Xto use standard input or standard output unless specifically redirected.  In 
Xthe first example above, it might be necessary to put >/dev/tty0 on some lines
Xin the shell script myfile.  The same holds for the commands typed directly to
Xat.
X
X# badblocks
X
XCommand:	badblocks - put a list of bad blocks in a file
XSyntax:		badblocks block_special
XFlags:		(none)
XExample:	badblocks /dev/fd1
X
X     If a device develops bad sectors, it is important to not have them
Xallocated to important files.  This program makes it possible to collect
Xup to 7 bad blocks into a file, so they will not be allocated for a "real"
Xfile.  When the program starts up, it asks for a list of bad blocks.  Then
Xit creates a file whose name is of the form .Bad_xxxxx, where xxxxx is a pid.
X
X# cal
X
XCommand:	cal - print a calendar
XSyntax:		cal [month] year
XFlags:		(none)
XExample:	cal 3 1987		# print March 1987
X
X     Cal prints a calendar for a month or year.  The year can be between 1
Xand 9999.  Note that the year 87 is not a synonym for 1987, but is itself a
Xvalid year about 19 centuries ago.  The calendar produced is the one used
Xby England and her colonies.  Try Sept. 1752, Feb 1900, and Feb 2000.  If
Xyou don't understand what is going on, look up "Calendar, Gregorian" in a
Xgood encyclopedia.
X
X# cdiff
X
XCommand:	cdiff - context diff
XSyntax:		cdiff [-c] old new
XFlags:		-cN how much context to provide
XExample:	cdiff old new >f	# write context diff on f
X
X     Cdiff produces a context diff by first running 'diff' and then adding
Xcontext.  Some update programs, like patch, can use context diffs to update
Xfiles, even in the presence of other, independent changes.
X
X# chmod
X
XCommand:        chmod -- change file modes
XSyntax:         chmod mode file
XFlags:		(none)
XExample:        chmod 754 file           # Owner: rwx; Group r-x; Others r--
X
XOCTAL MODES:
X
X   These are constructed by ORing the appropriate modes from this list:
X   
X   4000    Set UID (Superuser only)
X   2000    Set GID (Superuser only)
X   1000    Sticky Bit (Superuser only)
X   0400    Read by Owner
X   0200    Write by Owner
X   0100    Execute by Owner
X   0070    Read, Write, Execute by Group
X   0007    Read, Write, Execute by Others
X
X# chown
X
XCommand:        chown -- change owner
XSyntax:         chown user file
XFlags:		(none)
XExample:        chown ast file1 file2     # Make ast the owner of the files
X
XThe owner field of the named files is changed to 'user' (i.e., login name
Xspecified).  Only the super-user may execute this command.
X
X# compress
X
XCommand:	compress - compress a file using modified Lempel-Ziv coding
XSyntax:		compress [-cdfv] [file] ...
XFlags:		-c Put output on standard output instead of on file.Z
X		-d Decompress instead of compress
X		-f Force output even if there is no saving
X		-v Verbose mode
XExamples:	compress <infile >outfile	# compress 1 file
X		compress x y z	# compress 3 files to x.Z, y.Z, and z.Z
X
X     The listed files (or standard input, if none are given) are compressed
Xusing the Ziv-Lempel algorithm.  If the output is smaller than the input,
Xthe output is put on file.Z or standard output if no files are listed.
X
X# cpdir
X
XCommand:	cpdir - copy a directory and its subdirectories
XSyntax:		cpdir [-v] srcdir destdir
XFlags:		-v Verbose; cpdir tells what it is doing
XExample:	cpdir dir1 dir2	# creat dir2 and copy dir1's files into it
X
X     Cpdir creates the target directory, goes into it, and copies all the
Xfiles in the source directory to it.  When it is done, the target directory
Xcontains the same files as the source directory.  Subdirectories are copied
XRecursively. Links and special files are ignored.
X
X# cron
X
XCommand:	cron - clock daemon
XSyntax:		cron
XFlags:		(none)
XExample:	/usr/bin/cron		# use absolute path in /etc/rc
X
X     Cron is clock daemon.  It is typically started up by including the
Xcommand /usr/bin/cron in the /etc/rc file.  Once started, cron puts itself
Xin the background, so no & is needed.  It runs forever, sleeping most of
Xthe time.  Once a minute it wakes up and examines /usr/lib/crontab to see
Xif there is any work to do.  If there is, the work is done.  The entries of
X/usr/lib/crontab contain 6 elements each.  Some examples follow:
X
X   min hr dat mo day   command
X    *  *   *  *   *    /usr/bin/date >/dev/tty0   #print date every minute
X    0  *   *  *   *    /usr/bin/date >/dev/tty0   #print date on the hour
X   30  4   *  *  1-5   /bin/backup /dev/fd1       #do backup Mon-Fri at 0430
X   30 19   *  *  1,3,5 /etc/backup /dev/fd1       #Mon, Wed, Fri at 1930
X    0  9  25 12   *    /usr/bin/sing >/dev/tty0   #Xmas morning at 0900 only
X
X# diff
X
XCommand:	diff - print differences between two files
XSyntax:		diff file1 file2
XFlags:		(none)
XExample:	diff file1 file2	# print differences between 2 files
X
X     Diff compares two files and generates a list of lines telling how
Xthe two files differ.  Lines may not be longer than 128 characters.
X
X# diskcheck
X
XCommand:	diskcheck - check a disk for bad sectors
XSyntax:		diskcheck device start count
XFlags:		(none)
XExamples:	diskcheck /dev/at0 0 1200	# check 1.2 MB floppy
X		diskcheck /dev/at0 100 1100	# check floppy from block 100
X
X     Diskcheck checks a disk for bad sectors by reading in each sector,
Xwriting a known bit pattern onto it, reading it back in and comparing with
Xwhat was written.  This check is then a second time.  Bad sectors are reported
XAfter each sector is tested, the original sector is restored.
X
X# dis88
X
XCommand:	dis88 - disassembler
XSyntax:		dis88 [-o] infile [outfile]
XFlags:		-o List the object code along with the assembly code
XExamples:	dis88 a.out >listing		# disassemble a.out
X		dis88 -o a.out listing		# ditto, but with object code
X
X     Dis88 is a disassembler.  It takes an executable file and prints the
Xsymbolic assembly code that corresponds to it.  If the executable file contains
Xa symbol table (added by the program ast), the symbol table information is used
Xto give a more readable asembly listing.
X
X# du
X
XCommand:	du - print disk usage
XSyntax:		du [-s] dir
XFlags:		-s Summary only
XExample:	du dir			# list disk space used by files in dir
X
X     Du examines a directory and prints the amount of space occupied by the
Xfiles in that directory and its subdirectories.
X
X# ed
X
XCommand:	ed - editor
XSyntax:		ed file
XFlags:		(none)
XExample:	ed prog.c		# edit prog.c
X
X    Ed is functionally equivalent to the standard V7 editor, ed.  It supports
Xthe following commands:
X	
X	(.)	a: append
X	(.,.)	c: change
X	(.,.)	d: delete
X		e: edit new file
X		f: print name of edited file
X	(1,$)	g: global command
X	(.)	i: insert
X	(.,.+1)	j: join lines together
X	(.)	k: mark
X	(.)	l: print with special characters in octal
X	(.,.)	m: move
X	(.,.)	p: print
X		q: quit editor
X	(.)	r: read in new file
X	(.,.)	s: substitute
X	(1,$)	v: like g, except select lines that do not match
X	(1,$)	w: write out edited file
X
XMany of the commands can take one or two addresses, as indicated above.  The
Xdefaults are shown in parentheses.  Thus 'a' appends to the current line, and
Xg works on the whole file as default.  The dot refers to the current line.
XBelow is a sample editing session with comments given following the # symbol.
X	ed prog.c		# edit prog.c
X	3,20p			# print lines 3 through 20
X	/whole/			# find next occurence of 'whole'
X	s/whole/while/		# replace 'whole' by 'while'
X	g/MAXBUF/s//MAX_BUF/g	# replace 'MAXBUF' by 'MAX_BUF' everywhere
X	w			# write the file back
X	q			# exit the editor
X	
X# expr
X
XCommand:	expr - evaluate experession
XSyntax:		expr arg ...
XFlags:		(none)
XExample:	x=`expr $x + 1`		# add 1 to shell variable x
X
X     Expr computes the value of its argument and writes the result on
Xstandard output.  The valid operators, in order of increasing precedence,
Xare listed below.  Operators grouped by {...} have the same precedence.
XOperators: |, &, {<, <=, ==, !=, >=, >}, {+, -}, *.
X     Note that the V7 ":" operator is missing.  Parentheses are permitted.
X
X# factor
X
XCommand:	factor - factor an integer less than 2**31
XSyntax:		factor number
XFlags:		(none)
XExample:	factor 450180	# print the prime factors of 450180
X
X     Factor prints the prime factors of its argument in increasing order.
XEach factor is printed as many times as it appears in the number.
X
X# fgrep
X
XCommand:	fgrep - fast grep
XSyntax:		fgrep [-cfhlnsv] [file] [string] [file] ...
XFlags:		-c count matching lines and only print count, not the lines
X		-f take strings from file named in following argument
X		-h omit file headers from printout
X		-l list file names once only
X		-n each line is preceded by its line number
X		-s status only, no output
X		-v print only lines not matching
XExamples:	fgrep # prog.c			# print lines containing # sign
X		fgrep -f pattern prog.c		# take strings from 'pattern'
X
X     Fgrep is essentially the same as grep, except that it only searches for
Xlines containing literal strings (no wildcard characters), and it is much
Xfaster.
X
X# file
X
XCommand:	file - make a guess as to a file's type based on contents
XSyntax:		file name ...
XFlags:		(none)
XExample:	file a.out /usr/include/ar.h	# guess at types
X
X     File reads the first block of a file and tries to make an intelligent
Xguess about what kind of file it is.  It understands about archives, C
Xsource programs, executable binaries, shell scripts, and English text.
X
X# find
X
XCommand:	find - find files meeting a given condition
XSyntax:		find directory expression
XFlags:		(none)
XExamples:	find /  -name a.out -print	# print all a.out paths
X		find /usr/ast ! -newer f -ok rm {} \;	# ask before removing
X		find /usr -size +20 -exec mv {} /big \; # move files > 20 blks
X		find / \( -name a.out -o -name `*.o` \) -exec rm {}\;
X
X     Find descends the file tree starting at the given directory checking
Xeach file in that directory and its subdirectories against a predicate.
XIf the predicate is true, an action is taken.  The predicates may be
Xconnected by -a (Boolean and), -o (Boolean or) and ! (Boolean negation).
XEach predicate is true under the conditions specified below.  The integer n
Xmay also be +n to mean any value greater than n, -n to mean any value less than
Xn, or just n for exactly n.
X  -name s	true if current filename is s (include shell wild cards)
X  -size n	true if file size is n blocks
X  -inum n	true if the current file's i-node number is n
X  -mtime n	true if modification time relative to today (in days) is n
X  -links n	true if the number of links to the file is n
X  -newer f	true if the file is newer than f
X  -perm n	true if the file's permission bits = n (n is in octal)
X  -user u	true if the uid = u (a numerical value, not a login name)
X  -grogp g	true if the gid = g (a numerical value, not a group name)
X  -type x	where x is bcdfug (block, char, dir, regular, setuid, setgid)
X
XFollowing the expression can be one of the following, telling what to do
Xwhen a file is found:
X  -print	print the file name on standard output
X  -exec		execute a MINIX command, {} stands for the file name
X  -ok		prompts before executing the command
X
X# fdisk
X
XCommand:	fdisk - partition a hard disk
XSyntax:		fdisk file
XFlags:		(none)
XExample:	fdisk /dev/hd1
X
X     When fdisk starts up, it reads in the partition table and displays it.
XIt then presents a menu to allow the user to modify partitions, store the
Xpartition table on a file, or load it from a file.  Partitions can be marked
Xas DOS or non-DOS, and active or not.  MINIX doesn't care what kind of a
Xpartition it uses.  Using fdisk is self-explanatory.  However, be aware that
Xrepartitioning a disk may cause information on it to be lost.  Rebooting the
Xsystem is mandatory after changing partition sizes.  MINIX, XENIX, PC-IX, and
XMS-DOS all have different ideas about how partitions are numbered.
X
X# fix
X
XCommand:	fix - generate new file from old one and diff listing
XSyntax:		fix oldfile difflist >newfile
XFlags:		(none)
XExample:	fix old difflist >new	# generate new from old and diffs
X
X     Fix accepts a diff listing produced by diff and reconstructs the
Xnew file.  It is common for people to take a file, modify it, and then
Xsend the diff listing between the old and new files to other people.
XUsing fix, the old file, and the diff listing, it is possible to creat
Xthe new file.  For example:
X
X  diff oldfile newfile >difflist
X  fix oldfile difflist >new2
X
Xwill generate a file new2 that is identical to newfile.
X
X# from
X
XCommand:	from - input half of a connection
XSyntax:		from port
XFlags:		(none)
XExamples:	from port | sort >x	# fetch and sort an incoming file
X		from port | sh		# primitive sherver
X
X     To and from are used together to provide connection-oriented service.
XOn the sending machine, the last member of a pipeline is 'to port'.  On the
Xreceiving machine, the first member of a pipe line is 'from port'.  The net
Xresult is that the output of the sending pipeline goes into the input of the
Xreceiving pipeline, making pipelines work across the network. 
X
X# fsck
X
XCommand:   	fsck - perform file system consistency check
XSyntax:	   	fsck [-aclmrs] [device] ...
XFlags:	   	-a automatically repair inconsistencies
X	   	-c inode ...	check and list only the specified inodes
X	 	-l list the files and directories in the filesytem
X	  	-m make a new file system
X	   	-r prompt user for repairs if inconsistencies are found
X	  	-s list the superblock of the file system
XExamples: 	fsck /dev/hd4	# check file system on /dev/hd4
X	 	fsck -a /dev/at0	# automatically fix errors on /dev/at0
X	   	fsck -l /dev/fd0	# list the contents of /dev/fd0
X	   	fsck -c 2 3 /dev/hd3	# check and list inodes 2 & 3 on /dev/hd3
X
X     Fsck performs consistency checks on the file systems which reside on the
Xspecified devices.  It may also be used to list the contents of a file system 
Xor to make a new file system.
X
X# help
X
XCommand:        help -- provide brief command explanations
XSyntax:         help [command]
XFlags:          (none)
XExample:        help chown
X
XLooks in $HELPDIR/$HELPFILE (/usr/lib/ and helpfile are the defaults) for
Xexplanations of a command.
X
X# lorder
X
XCommand:	lorder - compute the order for library modules
XSyntax:		lorder file ...
XFlags:		(none)
XExample:	lorder proc1.s proc2.s
X
X     Lorder accepts a series of packed or unpacked .s files and libraries,
Xand produces a partial ordering suitable for processing by tsort.
X
X# master
X
XCommand:	master - control the creation of shervers
XSyntax:		master count uid gid command
XFlags:		(none)
XExample:	master 2 1 1 /usr/bin/sherver port
X
X     If a machine is intended to be used as a server, its /etc/rc file should
Xhave a command similar to the example above.  When the system is booted, master
Xruns and forks off the required number of shervers (max 4).  They run with the
Xindicated uid and gid, and listen to the indicated port.  When an rsh is done
Xon a client machine, the command is given to one of the shervers for execution.
XWhen the sherver is done, it exits, master, which is always running, sees this,
Xand creates a new sherver.  Thus master is very similar to init, only it makes
Xnew shervers (usually) instead of new login programs.  Master must run as root
Xto be able to do setuid and setgid.
X
X# more
X
XCommand:	more - pager
XSyntax:		more file ...
XFlags:		(none)
XExample:	more file		# display file on the screen
X
X     More is an alternative to mined as a pager, for people used to the
X4.x BSD pager.  This version only implements three commands:
X   <space>  - display next page
X   <return> - display next line
X   q        - exit more
X
X# nm
X
XCommand:	nm - print name list
XSyntax:		nm [-gnopru] [file] ...
XFlags:		-g print only external symbols.
X		-n sort numerically rather than alphabetically.
X		-o prepend file name to each line rather than only once.
X		-p don't sort, print in symbol-table order.
X		-r sort in reverse order.
X		-u print only undefined symbols.
XExamples:	nm -n a.out		# print all symbols in numerical order
X		nm -g a.out		# print global symbols alphabetically
X
X    Nm prints the symbol table of executable files when it is available.
XIf no file is given, the symbols in a.out are used.  The format of the table 
Xis somewhat compatible with the one produced  by asld when used with the -s 
Xoption. The symbol table can be added with ast.  Archives are not supported. 
XNote that assembly language files don't have symbol tables.
X
X# paste
X
XCommand:	paste - paste multiple files together
XSyntax:		paste [-s] [-ddelim] file ...
XFlags:		-s print files sequentially, file k on line k
X		-ddelim set delimiter used to separate columns
XExamples:	paste file1 file2	# print file1 in col 1, file2 in col 2
X		paste -s f1 f2 f3 f4	# print f1 on line 1, f2 on line 2, etc
X
X     Paste displays multiple files in parallel.  Suppose a set of k files each
Xhave one word per line.  Then the paste output will have k columns, with the
Xcontents of file j in column j.  The columns are separate by tabs unless the
Xseparator is changed with the -d flag.  If the -s flag is given, then the first
Xfile is on line 1, the second file on line 2, etc.  In effect, -s turns the
Xfiles sideways.
X
X# patch
X
XCommand:	patch - patches up a file from the original and a diff
XSyntax:		patch [-bcdDefFlnNop]
XFlags:		-b next argument is backup extension, instead of .orig
X		-c interpret the patch file as a context diff
X		-d cd to the next arg (assumed a dir) before doing anything
X		-D mark changes with "#ifdef...#endif"; next arg gives label
X		-e interpret the patch file as an ed script
X		-f forces patch to do its work without asking any questions
X		-F# sets the maximum fuzz factor
X		-l do matching loosely (e.g., all white space is equivalent)
X		-n interpret the patch file as a normal diff
X		-N ignore patches that are reversed or already applied
X		-o next argument is the output file name
X		-p# sets the pathname strip count
XExample:	patch file difflist		# fix up the file
X
X     Patch takes an original file and a diff listing and recreates the new
Xfile.  It is functionally similar to fix, but much more powerful.  Not only
Xcan it handle normal diffs, but also context diffs produced by cdiff.  In
Xaddition, it works even when the file being patched has other changes to it.
XIt deduces the type of difflist itself (unless given -c, -e, or -n).
XThe normal usage is given in the example above.  In this case patch will
Xmodify 'file' to incorporate all the patches.  The original file will be put
Xon 'file~.
X
X# prep
X
XCommand:	prep - prepare a text file for statistical analysis
XSyntax:		prep [file]
XFlags:		(none)
XExamples:	prep infile >outfile		# prep infile
X		prep <infile >outfile		# prep infile
X
X     Prep strips off most of the troff commands from a text file and then
Xoutputs all the words, one word per line, in the order they occur in the file.
XThis file can then be sorted and compared to a dictionary (as a spelling
Xchecker), or used for statistical analyses.
X
X# printenv
X
XCommand:	printenv - print out the current environment
XSyntax:		printenv
XFlags:		(none)
XExample:	printenv		# print the environment
X
X     Printenv prints out the current environment strings, one per line.
X
X# rcp
X
XCommand:	rcp - remote copy
XSyntax:		rcp [mach1]!file1 [mach2]!file2
XFlags:		(none)
XExamples:	rcp file mach1!/usr/ast/x	# local file to remote machine
X		rcp mach2!/usr/ast/x file	# fetch remote file
X
X     Rcp is not a program.  It is a shell script that does remote copying.  It
Xmakes use of the programs 'to' and 'from'.
X
X# readfs
X
XCommand:	readfs - read a MINIX file system
XSyntax:		readfs [-il] block_special [dir]
XFlags:		-i Give information about the file, but do not extract files
X		-l List the files extracted on standard output
XExample:	readfs -l /dev/fd0
X
X     Readfs reads a floppy disk containing a MINIX file system.  It can
Xextract all the files from it, give a listing of them, or both.  The files
Xextracted can be put in a user-specified directory (default: current
Xdirectory).  If subdirectories are needed, they will be created automatically.
X
X# rsh
X
XCommand:	rsh - remote shell for networking
XSyntax:		rsh port [-beil]
XFlags:		-b start the rsh in the background
X		-e keep stderr separate from stdout
X		-i take input from the local process
XExamples:	rsh machine5 ls -l /usr/bin	# list remote bin directory
X		rsh abc cat /usr/doc/f >f	# fetch remote file
X		rsh foobar			# log onto remote machine
X
X     The remote shell command is the way to have a distant server carry out
Xa command over the Ethernet.  The port given as the first argument can be
Xany string of up to 6 characters, but it must match the port used by some
Xsherver.  The command will be executed and the results returned on stdout.
XUnless the -e flag is given, the remote stderr and stdout are merged onto the
Xlocal stdout.  Giving rsh with just a port and no argument is the standard way
Xto log onto a remote machine.
X
X# sherver
X
XCommand:	sherver - shell server
XSyntax:		sherver port
XFlags:		(none)
XExample:	sherver machine1
X
X     The rsh command does its remote execution by doing a remote procedure call
Xto some sherver.  The sherver executes the command and then exits.  Usually a
Xmaster will be running to make a new one.  Because shervers get their input 
Xfrom a pipe, remote execution cannot handle signals and CTRL-D, because they
Xcannot be sent down a pipe.
X
X# spell
X
XCommand:	spell - print all words in a file not present in the dictionary
XSyntax:		spell file
XFlags:		(none)
XExample:	spell document		# print the spelling errors on stdout
X
X     Spell is the MINIX spelling checker.  It is actually a short shell script.
XFirst, the program prep strips off the roff, nroff, and troff control lines,
Xand the punctuation, and lists each word on a separate line.  These words are
Xthen sorted.  The resulting output is then compared to the dictionary.  Words
Xpresent in the file but not present in the dictionary are listed.  The
Xdictionary should be located in /usr/lib (or the shell script changed).
X
X# strings
X
XCommand:	strings - print all the strings in a binary file
XSyntax:		strings file ...
XFlags:		(none)
XExample:	strings a.out		# print the strings in a.out
X
X     Strings looks for sequences of ASCII characters followed by a zero byte.
XThese are usually strings.  This program is typically used to help identify
Xunknown binary programs
X
X# strip
X
XCommand:	strip - remove symbol table from executable file
XSyntax:		strip [file] ...
XFlags:		(none)
XExample:	strip a.out		# remove symbols from a.out
X
X    For each file argument, strip removes the symbol table.  Strip makes a 
Xcopy of the file being stripped, so links are lost.
X
X# term
X
XCommand:	term - turn PC into a dumb terminal
XSyntax:		test [baudrate] [parity] [bits_per_character]
XFlags:		(none)
XExamples:	term 2400		# talk to modem at 2400 baud
X		term 1200 7 even	# 1200 baud, 7 bits/char, even parity
X		term 8 9600		# 9600 baud, 8 bits/char, no parity
X
X     Term allows MINIX to talk to a terminal or modem over RS232 port 1.  The
Xprogram first sets the baudrate, parity and character length, and then forks.
XThe parent sits in a loop copying from standard input (usually the console's
Xkeyboard), to the terminal or modem (/dev/tty1).  The child sits in a loop
Xcopying from the terminal or modem (/dev/tty1) to standard output.  Thus when
XRS232 port 1 is connected to a modem, every keystroke typed on the keyboard
Xis sent to the modem, and every character arriving from the modem is displayed.
XStandard input and output may be redirected, to provide a primitive file
Xtransfer program, with no checking.  To exit term, type three ESC characters.
XImportant note: to use term, it is essential that /etc/ttys is configured so
Xthat there is no shell hanging on /dev/tty1.  If there is, both the shell and
Xterm will try to read from /dev/tty1, and nothing will work.
X
X# termcap
X
XCommand:	termcap - print the current termcap entry
XSyntax:		termcap
XFlags:		(none)
XExample:	termcap			# print the termcap entry
X
X     Termcap reads the /etc/termcap entry corresponding to the current shell
Xvariable $TERM.  It then prints out all the parameters that apply.
X
X# test
X
XCommand:	test - test for a condition
XSyntax:		test expr
XFlags:		(none)
XExample:	test -r file		# see if file is readable
X
X     Test checks to see if files exist, are readable, etc. and returns
Xan exit status of zero if true and nonzero if false.  The legal operators are
X  -r file  true if the file is readable
X  -w file  true if the file is writable
X  -x file  true if the file is executable
X  -f file  true if the file is not a directory
X  -d file  true if the file is a directory
X  -s file  true if the file exists and has a size > 0
X  -t fd    true if file descriptor fd (default 1) is a terminal
X  -z s     true if the string s has zero length
X  -n s     true if the string s has nonzero length
X  s1 = s2  true if the strings s1 and s2 are identical
X  s1 != s2 true if the strings s1 and s2 are different
X  m -eq m  true if the integers m and n are numerically equal
X                The operators -gt, -ge, -ne, -le, -lt may be used as well
X
XThese operands may be combined with -a (Boolean and), -o (Boolean or), !
X(negation).  The priority of -a is higher than that of -o.  Parentheses are 
Xpermitted, but must be escaped to keep the shell from trying to interpret them.
X
X# to
X
XCommand:	to - output half of a connection
XSyntax:		to port
XFlags:		(none)
XExample:	cat f1 f2 | to mach4	# send the catted files to port
X
X     To and from are used together to provide connection-oriented service.
XOn the sending machine, the last member of a pipeline is 'to port'.  On the
Xreceiving machine, the first member of a pipe line is 'from port'.  The net
Xresult is that the output of the sending pipeline goes into the input of the
Xreceiving pipeline, making pipelines work across the network. As a simple
Xexample, consider:
X	on machine1:	cat f1 f2 | to Johnny
X	on machine2:	from Johnny | sort >x
XThe effect of these two commands is that the files f1 and f2 are concatenated,
Xtransferred to machine 2, and sorted their, with the output going to a file x
Xon machine 2.  The string Johnny is used by the transaction system to identify
Xwhich sender goes with which receiver; any unique string can be used.
X
X# traverse
X
XCommand:	traverse - print directory tree under the named directory
XSyntax:		traverse dir
XFlags:		(none)
XExample:	traverse .		# print tree starting at working dir
X
X     Traverse prints the tree structure starting at the named directory.  All
Xthe subdirectories are listed, with the depth shown by indentation.
X
X# tsort
X
XCommand:	tsort - topological sort
XSyntax:		tsort file
XFlags:		(none)
XExample:	ar cr libc.a `lorder *.s | tsort`	# build library
X
X     Tsort accepts a file of lines containing ordered pairs and builds a
Xtotal ordering from the partial orderings.
X
X# treecmp
X
XCommand:	treecmp - recursively list differences in two directory trees
XSyntax:		treecmp [-v] dir1 dir2
XFlags:		-v (verbose) list all directories processed
XExample:	treecmp -v /usr/ast/V1 /usr/ast/V2
X
X     Treecmp recursively descends the directory tree of its first argument
Xand compares all files to those at the corresponding position in the second
Xargument.  If the two trees are identical, i.e., all the corresponding
Xdirectories and files are the same, there is no output.  Otherwise, a list
Xof files missing from one of the trees or present in both but whose contents
Xare not identical in both are printed.
X
X# tty
X
XCommand:	tty - print the device name of this tty
XSyntax:		tty
XFlags:		(none)
XExample:	tty
X
X     Print the name of the controlling tty.
X
X# vol
X
XCommand:	vol - split standard input into diskette-sized volumes
XSyntax:		vol [-u] size block-special
XFlags:		-u unsave from diskettes
XExamples:	tar c - . | vol 360 /dev/fd0	# prompt for disk every 360K
X		vol -u 360 /dev/fd0 | tar x -	# restore a saved file system
X
X     It occasionally happens that a program generates an output stream intended
Xfor diskette but the stream is to large to fit on one diskette.  Vol is a
Xprogram that accepts such a stream, and pauses every n blocks to request a
Xnew diskette to be inserted.  This makes it possible to save arbitrarily long
Xstreams on a series of diskettes, as shown in the examples above.
X
X# whereis
X
XCommand:	whereis - examine system directories for a given file
XSyntax:		whereis file
XFlags:		(none)
XExample:	whereis	stat.h		# prints: /usr/include/sys/stat.h
X
X     Whereis searches a fixed set of system directories, /bin, /lib, /usr/bin,
Xand others, and prints all occurrences of the argument name in any of them.
X
X# which
X
XCommand:	which - examine $PATH to see which file will be executed
XSyntax:		which name
XFlags:		(none)
XExample:	which a.out		# tells which a.out will be executed
X
X     The $PATH shell variable controls the MINIX search rules. If a command
Xa.out is given, the shell first tries to find an executable file in the working
Xdirectory.  If that fails, it looks in various system directories, such as /bin
Xand /usr/bin.  The which command makes the same search and gives the absolute
Xpath of the program that will be chosen.
X
X# who
X
XCommand:	who - print list of currently logged in users
XSyntax:		who
XFlags:		(none)
XExample:	who			# print user names, terminals and times
X
X     Who prints a list of currently logged in users.  For each one, the user
Xname, terminal, and login time is printed.  This program gets its information
Xfrom the file /usr/adm/wtmp, which is updated by init and login.  If the file
Xdoes not exist, neither of these will create it, and 'who' will not work.  Note
Xthat if you decide to create an empty /usr/adm/wtmp to enable the login
Xaccounting, it will grow forever and eventually fill up your disk unless you
Xmanually truncate it from time to time.
X
X# whoami
X
XCommand:	whoami - print current user name
XSyntax:		whoami
XFlags:		(none)
XExample:	whoami			# print user name
X
X     In case you forget who you are logged in as, whoami will tell you.  If
Xyou use 'su' to become somebody else, whoami will give the current effective
Xuser.
X
X# uuencode
X
XCommand:	uuencode - encode a binary file to ASCII (e.g., for mailing)
XSyntax:		uuencode [input] output
XFlags:		(none)
XExample:	uuencode infile <infile >outfile	# encode infile
X
X     Uuencode takes an input file, typically a binary file, and converts it
Xto pure ASCII by encoding 3 bytes (24 bits) as 4 bytes in ASCII.  Only 64
Xdifferent characters are used, all of them valid ASCII characters.
X
X# uudecode
X
XCommand:	uudecode - decode a binary file encoded with uuencode
XSyntax:		uudecode file 
XFlags:		(none)
XExample:	uudecode encodedfile 	# re-create the original file
X
X     Uudecode takes an input file, typically a uuencoded binary file, and 
Xconverts it back to the original file.  The decoded file is given the name
Xthat the original file had.  The name information is part of the encoded file.
X
X
/
echo x - info
sed '/^X/s///' > info << '/'
X:
X# info - shellscript to use help command as a notebook lookup
Xexport HELPDIR HELPFILE
XHELPDIR=$HOME
XHELPFILE=$HOME/.notebook
Xhelp $1
/
echo x - info.save
sed '/^X/s///' > info.save << '/'
X:
X# info - shellscript to use help command as a notebook lookup
Xexport HELPDIR HELPFILE
XHELPDIR=$HOME
XHELPFILE=$HOME/.notebook
Xhelp $1
/
echo x - makefile
sed '/^X/s///' > makefile << '/'
X#
X# Makefile for Help command
X#
X#  By:     $Author: plocher $  (John Plocher)
X#          $Revision: 1.0 $
X#  Last modified:  $Date: 87/12/26 23:34:30 $
X#  Source is in:   $Source: /u/microport/src/help/RCS/Makefile,v $
X#
X#  Release state:  $State: Posted $
X#
X# Modification Log
X# ----------------
X#
X# $Log:    Makefile,v $
X# Revision 1.0  87/12/26  23:34:30  plocher
X# Initial revision
X# 
X#
X#  $Header: Makefile,v 1.0 87/12/26 23:34:30 plocher Posted $
X#
X
XSHELL=/bin/sh
X
X# Where you put your local binaries...
XLOCAL= /usr/local
XHELPDIR= /usr/lib
XCFLAGS= -T/usr/tmp -o
X 
Xhelp: 
X    cc $(CFLAGS) help help.c
X
Xinstall:
X   chown root help
X   chmod 755 help
X   chmod u+s help
X   if [ -f /usr/bin/help ] ; then  mv /usr/bin/help /usr/bin/help.SV ; fi
X   rm -f $(LOCAL)/help
X   cp help $(LOCAL)
X   chown root helpfile
X   chmod 644 helpfile
X   install -c $(HELPDIR) helpfile
X
Xuninstall:
X   rm -f $(LOCAL)/help $(HELPDIR)/helpfile $(HELPDIR)/helpfile.idx
X
Xclean:
X   rm -f help.s help
/
echo x - readme
sed '/^X/s///' > readme << '/'
XSubject: 286 Source: A Help Command for systems with limited disk space
XMessage-Id: <8712221357.AA29111@killer.UUCP>
XDate: 22 Dec 87 13:57:22 CST (Tue)
X
XRCSINFO: $Header: README,v 1.0 87/12/18 18:22:29 wnp Posted $
X
XThe enclosed is a "help" command, patterned after the help command
Xdistributed with MKS Toolkit -- in fact, if you have the Toolkit,
Xyou could use their helpfile as a starting point for a UNIX SysV
Xhelpfile.
X
XIf you don't have the Toolkit, you can construct a helpfile by
Xgleaning short command descriptions from your manual, and adding
Xthem to "/usr/lib/helpfile", according the the pattern of the partial
Xhelpfile shown below.
X
XI find this help command more useful than the help system distributed with
XSystem V, especially on machines with limited disk space, where it is not
Xpractical to keep the manuals on-line.
X
XThe program uses an indexfile, /usr/lib/helpindex, to speed up access;
Xif the indexfile does not exist, or is older than /usr/lib/helpfile (indicating
Xthat the helpfile has been updated), the program will build a new indexfile.
X
XCompile normally, (small model on Uport V/286), then invoke as "help". The
Xprogram should be owned by root and suid, so it can write in /usr/lib (to
Xrecreate the index file as needed.).
X
XThe helpfile below consists of those help entries which I have added to
Xthe MKS Toolkit file to use with my UNIX system. I do not feel free to
Xpost the MKS helpfile, since it is no doubt (c) by MKS.
X
XPut the helpfile into /usr/lib/helpfile, or change the references thereto in
Xhelp.c.
X
XI hope this is helpful. Civil and constructive comments are invited to
Xihnp4!killer!dcs!wnp, flames should be directed to /dev/null.
X
XWolf N. Paul
Xihnp4!killer!dcs!wnp
X
X
XP.S. Since first posting this to comp.unix.microport, another application
Xhas been suggested for this command - an online, free-form notebook.
X
XActually, any kind of information can be kept in a "helpfile" for this
Xcommand, as long as each item of info starts with a line containing
X'#' and a number of keywords separated by commas (currently each keyword
Xmust be less than 14 characters long and cannot contain white space).
XJohn Plocher's addition of looking at $HELPDIR and $HELPFILE permits one
Xto put info into a file $HOME/.notebook, and to access it using the enclosed
X"info" shellscript.
X
XAgain, i hope this i helpful.
/