Home
Your First Use of c./NIX •••••••••••••••••••••••••• 8
Contents
1. trouble Trouble Shooting on C NIX wildcard Filename Wildcards and C NIX Commands Chapter cmd 2D commands Summary of C NIX Commands 25 cat Concatenate or Type Files 00909060000900000000 9 26 chdir Changing Printing Current Working Directory 27 chmod Change File Mode Flags 28 cp Copy a File or Files 29 csh The C NIX tm Shell v ee 06060900000900000000000600909 9 30 Command Format and Search Path 30 Command Files 9 9 99 9 99 9 8 3 Exit Status e 909000090009000009000000900900000090090009 33 echo Echo a string 6 6 66 66 666 666666669669699 99996 34 exit Exit C NIX Shell 9 906 0000 9009 9 00 0 000009009090 09609909 35 grep Generalized Regular Expression Parser 36 help Help From the On Line User s Manual 38 ls List Directory 9090909909090909000000009000000000000 40 mkdir Make and Remove Directories 42 mkrel Make Page Relocatable Program 43 mv Move a File or Files e e 000 090000909090909009000090000 9 9 44 rm Remove File or Files 45 set Set Console Output Modes ecco ooo 46 walk Walk the Directory Tree 47 C NIX Subroutines
2. 18 directory tree walking 47 directory changing 27 directory current 18 directory making 42 directory printing current 27 directory top level 10 18 56 Index diskettes restrictions on changing 9 display directory sizes 40 display file sizes v v9 9 90909 90 99290909 40 display working directory 27 double spaced output 9999 9 9 15 drives for temp files changing 16 dynamic memory allocation 53 echo command eeccccc c60000 25 32 34 echo in command files 9990906006 060 0 90 32 era command 12 25 45 erase a file eecc 000606000000000 00090 45 escape characters eeeooeoooooooooo 21 examples e99006 006009000900000000000 38 executable flag 99606999 09099009009000 40 exit command 9 25 35 exit status eeeoeoooooo o 33 52 exit subroutine v e900 09906 00000 900099 52 exiting C NIX 99999 9 35 faster execution veec0 90o069009000029299 9 43 fclose subroutine 48 51 features v 0 9 060 06 000 0600000 0 9009000092099 5 features introduction to 10 fflush subroutine w 0e 06990906 99299 48 54 file flags 9 00 0 9099 9 28 file modes w 99 0 0 0 0099 0990900009 99 0960909 40 file names display 40 f
3. 16 pathname 99949 9 9 8 10 18 pathnames searching all 47 pattern matching 9 99 36 pipes 9 9999 9 9 9 20 30 pipes problems with 22 power off pre files 999899 989899 8 9 8 9 43 print working directory 27 problems vw 0 0 90 9 0 0990009009 0090 90 000099 9 4 putc subroutine 0 99 066 0 48 54 putchar subroutine 48 54 pwd command 99 9990909090 000 0 10 25 27 9 0 0060 90 9090 09 0 090900 09009 0920909 9 quoting RON s 21 read only flag 9 6 0 99 99906 9060929909 28 40 redirection I O ll 13 30 redirection problems with 22 regular expression 36 relocatable programs 43 removing directory 42 ren command 2D 44 rename a file eee ooo ooo oo 44 requirements disk 5 requirements memory 5 restrictions on changing diskettes 9 rm command 99999 9 12 25 45 rmdir camnand 9 9 9 99 99 996 496 25 42 SAVE unsupported 9999 9 9 23 saving program output 13 Screen paging of output 9 12 Screen paging changing 16 search for files 9 9999 9 9
4. lush ilep putchar c DESCRIPTION The subroutines putc and putchar provide standardized means for character output either buffered to a disk file or to the console output The FILE pointer passed to putc must have been the result of an fopen or be one of the standard file pointers stdout or stderr Putc to a disk FILE pointer adds a character to an internal buffer and then actually writes it to the disk when the buffer is full The fflush subroutine may be used to flush partial buffer fulls on CP M or C NIX it can only flush in units of the basic 128 byte sector An fclose must be performed when done SO that the final partial buffer full is written terminated by the CP M text end of file indicator control Z see fopen subr Putc c stdout is equivalent to putchar c see below Putc c stderr puts the character out using the direct console I O BDOS call thereby bypassing normal C NIX output re direction but see gt amp in ioredir info The putchar subroutine puts out the character using the console output BDOS call If output has been re directed the character will actually go to a file For all of the put routines if the character is the C newline Nn then a carriage return Nr is put out first except if the file was opened in binary mode see fopen subr FILES stdio h stdio c fileio c SEE ALSO fopen subr ioredir info strutils subr Standard String Utilities struti
5. part or 3 character extension part of a filename In addition a may be used at the end of the name part or extension part and it is equivalent to a string of question marks If a appears at the end of a name and no extension is specified all extensions are matched This is compatible with UNIX but differs from CP M in which only the null extension would be matched a c matches all files whose name starts with a and whose extension is l cnix b a matches all files whose name matches cnix b and extension starts with a foo matches all files whose name starts with foo regardless of extension The CP M equivalent would be foo which also works on C NIX Use foo to match files with no extension At the end of the name part or extension part matches a blank this is consistent with CP M Unlike in UNIX to maintain compatibility with existing CP M programs wildcarded filenames are expanded ONLY for the following commands chmod cmd cp cmnd dir ls cmd era rm cmnd grep cmnd mv cmnd In addition existing CP M programs or your own programs may recognize the wildcard characters A main startup routine is provided on the C NIX source disk for this purpose see main subr SEE ALSO intro info pathname info ls cmnd main subr LIMITATIONS The limitation that may only appear at the end of the name part or the extension part should be removed from CPM as well 34 commands
6. as follows command paraml lt predefined input The predefined input may include references to the command file parameters using l 2 as usual To display prompts and general commentary on the terminal while a command file is running an echo command is provided which simply echoes its parameters after doing 1 substitution echo Please wait while I crunch on 1 and 2 When this command is encountered by the shell it will display on the console output Please wait while I crunch on foo txt and bar c for example presumably informing the user of a coming pause in output This same effect can be accomplished using cat lt Please wait while I crunch on 1 and 2 See above and cat cmnd To include comments which are not echoed when encountered in the command file Start the line with a semi colon or introduce them with a double dash Comments continue to the end of the line This is a full line comment cc 1 0 1 c This is a partial line comment Conditional or repetitive execution can be accomplished by piping the output of a program into the shell For example suppose you write a program called if which evaluates its first argument and then outputs its second or third argument depending on whether the result is true or false This could provide a primitive conditional execution facility as follows if 51 help echo Usage Funclist source ada output lst
7. grep n function 1 sort 2 esh 32 csh cmnd The C NIX tm Shell csh cmnd If the expression evaluates to true i e the first command file parameter were help then the echo command is piped to the sub shell Otherwise the grep sort command is piped to the sub shell Remember that in such an example a program like the hypothetical if above is not actually executing the commands but rather piping the text to the shell to interpret EXIT STATUS If you are writing a program and want it to abort any command file it is part of you can do so by exiting with a negative exit status This is done by calling the exit function provided in the file cmain c see main subr passing the exit status directly to BDOS function 108 ignored by normal CP M 2 2 and then returning or jumping to address zero warm start Codes 256 129 are user definable fatal error codes Codes gt 0 indicate success Codes 128 2 are reserved for CP M 3 0 Code l is used to retrieve the current exit status e g x bdos 108 1 Upon return from a program the C NIX shell retrieves the value using BDOS function 108 and if it is negative it ignores the rest of the current command file or typed command line The exit status is initialized to a positive value so as to accommodate those commands which do not set its value at all NOTES If your own program has the same name as a built in C NIX shell command you can get
8. or display predefined text It simply reads each file and outputs it to the console By using output redirection the files can be effectively concatenated The second form shows the use of output appending gt gt to concatenate one ASCII file onto the end of another If no arguments are given to cat it simply copies its console input to the console output The third form above shows how this can be used in a command file to display some predefined text or see also echo omnd Type is a synonym for cat in C NIX and may be used in all of the same ways as well as in the more conventimal file display use illustrated in the last SYNOPSIS form The filename represents by convention the console input A user may thus insert some console provided text between two files in a concatenation cat header txt trailer txt combo txt After copying header txt cat will wait for input from the console copying it to console output until it receives the CP M end of file character control 2 It will then copy over trailer txt NOTES In the first SYNOPSIS form above the file output is created before the command actually begins and if it is also mentioned as one of the input files an infinite loop will be created Cat looks for the CP M ASCII end of file indicator control 2 and hence cannot be used to concatenate binary files SEE ALSO cp cmnd ioredir info echo cmnd LIMITATIONS Cat does not properly deal with wildc
9. 0 006 00 00 0099 52 main subroutine 48 making directory v 00 9 0 0 09 0 000 00209009 42 malloc subroutine 48 53 man command 7 25 38 manual pages 38 manual pages notation for 38 manual how to use 09060 96 9990096 09 06 299 3 manual organization of 3 manual starting with eeseeeea eo veg eeene 4 memory allocation routines 53 memory requirements 5 Microsoft BASIC 9999 23 missing files 9 99999999 22 mkdir command 9 0 9 06 4 25 42 mkrel command 25 43 modes file 9 99 99 9 9 40 move a file 999 9 99 8 8 9 44 mv command 25 44 mvbytes subroutine 48 55 87 Index names of files display 40 notation for manual pages 38 notes v e 0 09 0900900 900 099 00 9090 090 0000 090290909 38 organization of manual 3 output redirection eeeee eon ee ee eee page relocatable programs 43 paging 99999 9 9 46 paging output eecoeceesoovesecese 9 12 paging changing 9 9 9 16 patching defaults 9 999 0 0
10. Chapter subr 48 subrs C Subroutines for C NIX cccccccccccccccees 48 bdos C Interface to BDOS Calls 49 getc Standard Buffered Character Input 50 fopen Buffered File Opening and Closing 5l main Hidden Main Routine Exit Routine 52 malloc Dynamic Memory Allocation and Release 53 putc Standard Buffered Character Output 54 strutils Standard String Utilities 55 Index 0090 0 56 Software copyright 1985 C Craft Manual copyright 1984 C Craft copyright c 1985 The Software Toolworks Sale of this software conveys a license for its use on a single computer owned and operated by the purchaser Copying this software or documentation by any means whatsoever for any other purpose is strictly prohibited C NIX is a trademark of C Craft CP M is a registered trademark of Digital Research UNIX is a registered trademark of Western Electric C 80 is a trademark of The Software Toolworks Introduction to C NIX HOW TO GET STARTED C NIX is a software package which provides your 8 bit CP M 2 x system with many of the features of UNIX and MSDOS 2 0 It is intended primarily for use with hard disk or high capacity floppy disk systems and requires Version 2 of CP M not 1 x or 3 x In order to use C NI
11. NAME rm Remove File or Files SYNOPSIS rm f filel file2 era f filel file2 DESCRIPTION The rm command and its synonym era can be used to remove disk files If the filenames contain wildcard characters i e or see wildcard info then rm will by default ask for a confirmation The f flag will suppress this check as will running the command non interactively e g from a command file _ When rm asks for a confirmation the possible responses are n Do NOT remove files matching the wildcarded pattern y Remove files matching the pattern f Remove the files and suppress further confirmation checks for the duration of the command NOTES The rm command should NOT be used to remove sub directories Use the rmdir command mkdir cmnd instead SEE ALSO LIMITATIONS It should probably be illegal to remove a directory file like help sda because its associated sub directory might not be empty The error is not catastrophic however because if the file is simply recreated e g echo help sda the sub directory full of files will become reaccessible set cmnd Set Console Output Modes set cmnd NAME set Set Console Output Modes SYNOPSIS set cpbv cpbv DESCRIPTION The set command lets you turn off or on three modes which affect output on your screen The modes are verbose paging and confirmation The modes are turned on or off by the or flags respect
12. Patches to the C NIX System SYNOPSIS Address hex 022A 022C 0254 0255 0256 0257 0258 0259 025C 025D 025E 0260 DESCRIPTION Patches to the C NIX System Meaning First temporary drive letter Last temporary drive letter Drive for pipes 0 use C NIX drive Commands drive 0 not used searched for commands instead of drive A Help drive for help dir 0 use C NIX drive Confirm required if overwriting files in cp mv Verbose flag echo commands before execution in sub file SYS bit required for universal visibility of commands in top level directory Page screen output If paging number of lines page ASCII code to warn user at end of page e g 07 bell 3F 2 0 none etc Maximum user number to use for creating subdirectories Default J 4A M 4D 0 0 Oe oc n o 1 23 dec bell iF patches info Certain aspects of the C NIX system may be altered by patching the file cnixhigh sys The following example shows how to do this the drives above from their old defaults IMPORTANT A ddt b cnixhigh sys Load cnixhigh NEXT PC 0880 0100 s0254 Replace the pipe disk 0254 00 43 0255 00 44 0256 00 S22A 022A 4A 47 G 022B 00 g0 It changes three of Since the SAVE command does not work under C NIX it is necessary to perform this procedure under CP M not C NIX First free byte and start Make D the
13. be redirected with gt Possible Causes These characters have special meaning to C NIX See quoting info You did not select the disk on which cnix com resides before invoking it You removed the C NIX disk from the drive it started on Any non relocatable program is loaded over the shell and so the shell must be re loaded after it completes This process is fastest if cnix com is the first file copied onto the diskette so it is close to the directory tracks and contiguous Also some CP M configuration programs allow the user to reduce the stepping time Modern drives can handle a 6 millisecond step rate Files with the SYS flag set are not listed in the short form of ls or dir Files in other directories are not listed unless that directory is also specified The overlays for an editor or compiler are frequently required to be in the Current directory C NIX will find files in the top directory if the SYS flag is set chmod s Files with the write flag off cannot be moved or removed Use chmod w to set the write flag The disk is nearly full Move consists of a copy followed by a delete requiring room for two copies of the file temporarily The entire output of a piped command is collected in a temporary pipe file The pipe file disk must be writeable and with enough free space to hold it The program uses direct console output try gt amp or goes directly to the BIOS part of the oper
14. default buffer area 0x80 hex after expansion of filename wildcards and The zeroth argument argv 0 per UNIX convention represents the command name itself but will always be because CP M does not record the command name in the buffer area The argument count arge includes one for the command name and hence argv argc l is actually the last valid argument Argv argc is always a null pointer Besides expanding filename wildcards see wildcard info c main also removes quotes both and and backslashes except within parentheses Text within parentheses is passed as is including the parentheses themselves as a single argument If some arguments contain wildcards and no matches are found for any of them c main prints No match and aborts Wildcard characters within quotes are not expanded The exit routine should be called at completion of the program with a status value Exit records this value for use by the C NIX shell see csh cmnd by calling BDOS function 108 ignored by normal CP M and then jumps to zero for a warm start If the exit status value is negative the shell will interpret this as an error exit and abort any current command file or sequence FILES cmain c SEE ALSO csh cmd wildcard info LIMITATIONS When wildcarded filenames are expanded the resulting arguments should probably be sorted alphabetically instead of in directory order as they are now 69 malloc subr Dy
15. help topics List directories List current directory Display pages from manual help Display list of manual pages help Make directories Make page relocatable program Move rename a file Move files to new directory Print pathname of working directory chdir Rename a file mv Rename a file mv Remove files Remove directories mkdir Set certain user interface parameters Submit command file csh Type text files cat Walk directory tree Walk and execute command cmd chapter generally on a page devoted to that command In cases where the command is described elsewhere the name of that manual page is given in parentheses Optional flags are given in brackets with alternatives separated with vertical bars Ellipses are used to represent a list of files etc All of the above are recognized within the shell except for grep and mkrel All but these two and chmod mkdir and rmdir are also implemented entirely within the shell cnixutil pre SEE ALSO intro info The commands chmod mkdir and rmdir are implemented by OE ee cat cmnd Concatenate or Type Files cat cmnd NAME cat Concatenate or Type Files SYNOPSIS cat filel file2 output cat filel gt gt file2 cat lt predefined text type filel file2 DESCRIPTION The cat command alias type can be used to concatenate ASCII files type files
16. it will be created The third SYNOPSIS form is simple input redirection Instead of reading from the terminal the program takes its input from the specified infile when it requests console input The fourth SYNOPSIS form gt is used when a permanent record log of a program execution is desired in a logfile including both the program s console output and any console input When input is on the terminal any logged program output will also appear on the terminal The fifth SYNOPSIS form lt cause console input to be redirected from a file but with the side effect that it is echoed on the terminal as it is read This is useful during debugging of a program when the input is stored in a file The sixth SYNOPSIS form gt amp causes redirection of both normal console output and error output defined to be anything output using the BDOS direct console _ 13 ioredir info Input Output Redirection and Logging ioredir info output primitive system call 6 The seventh SYNOPSIS en lt eee is useful primarily within command files The text within parentheses is provided when the command requests console input The text may be several lines and may include nested balanced or quoted parentheses The final parenthesis becomes a carriage return followed by an end of file control Z when read by the command Note that this replaces the XSUB feature of standard CP M XSUB itself is not supported The eighth SYNO
17. pathnames see Hierarchical Directories below palp and you will get a listing of the contents of the help sub directory You will notice that the display stops after 23 lines To continue type any key on the keyboard This paging of screen output is a feature of C NIX which prevents information from moving off the screen before you can read it If you don t like it you can turn it off see set cmmd or patches info However the help command will always page Type out one of the files for example try type help intro hlp You should see this file The help command can also be used to accomplish the same thing For example type help intro help alone is roughly equivalent to ls help try it r When you are done with C NIX you may type bye or exit and you will return to CPM Alternatively you may simply power off the computer When you do turn off the power it is prudent to first open disk drive doors to lift the recording heads fram the medium The next time you boot up your operating system you can enter C NIX again by typing the command A CNIX How to Continue Now that you have run C NIX you may want to learn more about what it can do The first thing to read is the Notes for CP M Users section below which explains a number of concepts that are unique to C NIX You can then continue by reading the manual sections on the C NIX shell csh cmd help csh I O redirection and pipes ioredir info and pi
18. see mkdir cmnd When referring to a sub directory only the name part of the filename is used I e never mention the sd extension part Files in the top level directory of a disk which have the SYS flag set see chmod cmnd are accessible from any sub directory This works by having BDOS open function 15 automatically check the top level directory i e user 0 whenever a requested file is not found in the current directory File attribute f8 is set in the FCB so that subsequent reads and writes will reference the correct file This is particularly useful for executable programs and program overlays which are frequently referenced when working in a sub directory The C NIX shell recognizes the hierarchical directory pathname syntax and converts it to a form acceptable to CP M programs by temporarily defining logical disks with letters from j to m see patches info and replacing the hierarchical pathname part with simply j k etc Any parameter which contains un quoted slashes is translated in this way by the shell see quoting info SEE ALSO chdir cmd chmod cmd cp cmnd mkdir cmmd mv cad patches info quoting info walk cmnd LIMITATIONS For a single command only four temporary logical disks may be defined j k 1 and m thus limiting the number of sub directories which can be referred to with a single set of parameters This may be overcome by defining current directories of
19. than the one you boot up on This will work fine provided you always run the CNIX command from the current logged in drive For example if your C NIX files are on drive B make sure the prampt is B before running CNIX You can alter some of the ways C NIX interacts with the terminal to make the system more to your taste The system can page console output or not request confirmation or not before overwriting files from certain commands and print out more details of command files and certain commands as they execute See set cmnd and patches info for more details Your First Use of C NIX Now that you have installed C NIX you can run any CP M command or program or any of the C NIX commands First you may want to see a list of the files in the C NIX diskette top level directory AS ls 1 b if the C NIX disk is in B or simply AS ls 1 if you installed C NIX on A You should now see samething like the following although the totals will vary according to your disk format and C NIX version intro info Introduction to C NIX Features intro info rwx 28 6k cnix com rw 1 9k cnixhigh sys rwx 11 0k cnixutil pre rwx 10 4k grep pre drw 114 0k help sda rwx 3 0k set com Total 139k out of 241k If you installed the help files on your system disk you created a sub directory called help The next few commands will let you look at files in that sub directory For an explanation of directories filenames and
20. the name of the command file and any arguments as shown in the fourth form cmmdfile paraml In this case the shell is invoked implicitly This form will search multiple directories for omndfile see below The final form commandl shows the grouping of commands useful for piping or redirecting their I O as a whole This is equivalent to creating a command file with the parenthesized text and then running it Again the invocation of a sub shell to process the commands is left implicit COMMAND FORMAT AND SEARCH PATH The basic format of commands to the C NIX shell is similar to CP M x30 csh cmd The C NIX tm Shell csh cmd B command name paraml param2 param3 The prompt reminds the user of which is the current disk B in this case The chdir cmnd command may be used to change the current disk If the command name does not include a filename extension then the shell will try com normal CP M programs pre page relocatable programs loaded above C NIX shell built by mkrel cmnd or sub C NIX command files If the command name is not found in the current working directory the shell will look for it in certain other directories These directories make up the search path This is very useful because you don t have to keep copies of all _ your commands in each directory You can just keep one copy in a directory on the search path and use it from any directory at all The search path consists of
21. to it by prefixing its name with its explicit disk letter or by explicitly specifying the com extension or by renaming it with mv SEE ALSO intro info ioredir info patches info pathname info pipes info quoting info wildcard info cat cmnd exit cmnd grep cmnd mkrel cmnd LIMITATIONS In a few cases output files may appear double spaced when input is redirected see ioredir info for details The number of parameters and amount of text forming a single command line are limited to about 30 parameters and 250 characters of text By quoting or parenthesizing a single command line may in fact cross multiple lines Nevertheless these overall limits still apply Direct support for conditional and repetitive execution should be added to the shell although see if example above echo cmd Echo a string echo cmd NAME echo Echo a string Display a String on the Console SYNOPSIS echo anything at all DESCRIPTION The echo command displays the remainder of the command line on the terminal or standard output It can be used to display a message on the terminal during execution of a batch file 34 ue exit cmd Exit C NIX Shell exit cmd NAME exit Exit C NIX Shell Return to CP M or Invoking Shell SYNOPSIS exit bye DESCRIPTICN The exit command leaves the C NIX shell returning to CP M if this is a top level shell or to the invoking C NIX shell if this is a sub shell A
22. which the file cannot be moved or removed Chmod w sets the writeable flag while chmod w clears it The SYS flag controls whether files are visible in short form directory listings By default the flag is off and the file appears in the listing However when the SYS flag is set with chmod s the file is invisible and no longer appears in the short form listing In the long form listing ls l the SYS flag prints as an S See 1s cmnd Both the writeable and SYS flags may be turned on or off in a single chmod command as illustrated in the last form under SYNOPSIS above NOTES These flags correspond to CP M flags The C NIX writeable flag is the complement of the CP M read only flag The C NIX SYS flag is the same as the CP M SYS flag The flags are implemented using the high order bit of the first two characters of the filename extension when stored in the directory These flags have less effect on directory files e g help sda If the directory file is not writeable then the directory cannot be removed but components can still be added to or removed from it The SYS flag if set for a directory file will cause the directory file to be omitted from a short form listing of its parent directory but a short form listing of the directory itself will be unaffected Cammands in the top level directory of a drive are normally accessible from any sub directory If the SYS flag of a file in the top level director
23. 00000000 49 C NIX exiting from 35 C NIX first use of 8 C NIX installing eeeeveeeesecece 7 8 C NIX starting v ec 9e 06090000609090060009 6 cat command 9909 99 25 26 Cd cmd See chdir cmd change working directory 27 changing defaults 9 909 0 16 character output routines 54 character read routines 50 chdir command 99994 9 25 27 chmod command 25 28 cnixinit sub file 8 46 cnixutil pre file 9 cold boot 999994 8 8 8 command file aborting 33 command files 9 9999 090999 9 9 12 30 command files echo in eccccco 6c009 9 32 command format 30 command line limits On 33 Command processor 30 command search path 12 30 commands echo 9999 9 9 9 9 9 9 32 cat eeoeeouvuseeeeeeoeaeeoeoneaeeveoeee 26 cd 9999999909 see chdir cmd dir 99 99999 0 9 0 0 era 9 999 9 12 45 exit 99994996 9 grep 9 99 9 7 help 6 6 7 9 12 man 99999 999999 0 0 7 38 pwd 9 999999999999 0 10 27 re
24. 9 9 9 9 9 0 5 fopen subroutine 48 51 format of commands 30 free subroutine 48 53 Index getchar subroutine 48 50 getting started 9 999 96 3 grep command 7 25 36 grouping commands 30 help command 7 9 12 25 38 help drive changing 9 9 16 hierarchical directories 10 18 how to begin 09 00 9 9 00090 0 90 009090090090609 4 I O redirection ll 13 30 I O redirection problems with 22 input redirection 13 installing C NIX 7 8 introduction 9999 94 9 9 8 5 introduction to features 9999 2 oeee 10 invisible file 28 invoking the shelliaesseweckuekas 30 ioredir 999989 8 9 13 leaf vw 06 006 0 009 090 0900900090 0909 9 9 09 0 09 9 06292099 9 47 leaving C NIX 9999949 8 8 99 99 999 35 leaving shell v 9 006 06 90 006 06 929099 9000299 35 limitations 9989489489489 9899 38 limits on command line 33 list file names wrrrrrerrereee ee ey 40 list file sizes 0 9 9 99 9 9 9 ooo 40 ls command ccccccccccccccccces 25 40 main program e 0 09 000 0 6 0 006
25. 949 28 search path vw 0 0 09 0 90 0 000006 00909 12 30 searching all directories 47 Searching files 99 999909 999900 36 see ALSO 38 set command w 0 0 09 9 0 90999 09 0000 9 9090 46 Index shell exiting from Mom 35 shell invoking eee 30 size of files display 40 slow prompts eeoeoooooooooooo o 22 source code ev c 0 0 0090 09 0 0990 0009090099099 8 special characters 21 spoolers 999994 99 9 99 99 0 00 23 starting C NIX 99 0 9 6 starting with manual e eeoe ooo 0 4 startup command file 8 46 status at exit 99999 99 99 99 33 strany subroutine 48 55 strcmp subroutine 48 55 strcpy subroutine 48 55 streql subroutine 48 55 string functions 48 55 strlen subroutine 48 55 strutils 99949 9 0 55 subdirectories 10 18 subdirectory sizes display 40 submit command 999 99999 906900 oes 25 submit files 9 9999099909 0 0 12 30 subrs 9 00 9990 0 48 Switch eeoeoooooooooolo o ooo nooo ooo eee 21 switches e eeeooooooooo o ooo
26. A 02173 617 862 8177 9 10 AM and 8 10 PM Eastern only Recommendations for improvements to this manual are welcome as are all comments on C NIX There is a short trouble shooting guide in trouble info which tries to anticipate problems which may come up If you think you have really found a bug or undocumented limitation please make a record of a minimal sequence of operations which illustrates the problem Include the version number and date displayed when you start up C NIX Mail the information to C Craft at the address above Please enclose a self addressed stamped envelope if you wish an immediate reply We can only respond to problems raised by registered owners of C NIX SO we encourage you to fill out and mail the registration form ide intro info Introduction to C NIX Features intro info Installing C This section describes how to install C NIX on your system disk Boot up on your system disk and use the DIR command to make sure it contains the files Stat com and pip com These files are supplied with your CP M operating system Find out how much free space you have by typing the command A gt stat If you do not have at least 42K of space you will need to delete files in order to make that much roam before you can install C NIX Place the C NIX distribution disk in a floppy drive but not the drive you use for your system disk If your C NIX system came on more than one distribution disk use the one mar
27. PSIS form lists additional legal combinations of input logging output redirection appending and error redirection In all these cases means input logging amp means error redirection and gt gt means appending The flag in the final SYNOPSIS form allows overwriting of existing files by redirection Without the flag a file specified for output redirection logging with a single gt must NOT already exist If the input or output is to be redirected from or to the same file for a sequence of commands with the later ones picking up where the former ones leave off then the commands can be grouped into a command file see csh cmnd or directly with parentheses see example below Although not illustrated in the SYNOPSIS both input and output may be redirected for a single command EXAMPLES ddt prog com lt debug txt gt progddt log This example will start DDT with the given program taking commands fran the file debug txt showing them on the terminal as they are read due to lt and logging both input and output in the file progddt log due to gt type cover txt nroff body nr type backcovr txt gt lst This example runs a series of commands and sends all of their output to the listing device NOTES Enclosing commands in parentheses is equivalent to creating a command file with the enclosed text and then running it The text may be several lines and the end of a line unless quoted is equivalent to
28. The Software Toolw rks 14478 GLORIETTA DRIVE SHERMAN OAKS CALIFORNIA 91423 818 986 4885 C NIX Version 1 56 User s Manual January 1985 S Tucker Taft C Craft 22 Downing Road Lexington MA 02173 CONTENTS Introduction LO Q NIX desks sissies Ses How to Get Started 0 00 9000 0 0009 0 06 09 990900 90 9000 0 09 0 09099 9 Organization of this Manual Where to Begin Reading Problems and Comments General Information Chapter info eee intro Introduction to C NIX Features Making Backup Distribution Disks Running C NIX The Quick Way Installing C NIM 4295949929954 4399 944978 695 Advanced Installation Notes Your First Use Of C NIX cccccccccccccccccccccccce How to Continue 99999899 9 8 9 Notes for CP M USerS e Hierarchical Directories I O Redirection and Pipes The RESE ioredir Input Output Redirection and Logging patches Patches to the C NIX System L pathname Hierarchical Directory Pathname Syntax pipes C NIX Plpes 42 2 quoting Quoting and Escape Characters
29. X you will first have to install it on your system Then it will help for you to understand the new C NIX features you will have at your disposal You will not have to read very much of this manual in order to do that In fact following an old UNIX tradition most of this manual is not really meant to be read at all but simply to be referred to when you need information on a particular command However because these new features involve some complicated concepts like hierarchical file directories and input output redirection you should be sure to read carefully the few pages that will help you get started Those pages are the very next section entitled Introduction to C NIX Features We have tried to make this part easy to read In that section you will learn how to install and run C NIX and how to use same of the features The rest of this introduction tells how to find your way about the rest of the manual and how to report problems to us If you are impatient to get started you can skip to the next section now and return bere later ORGANIZATION OF THIS MANUAL This manual is organized following the long established tradition of UNIX manuals It s probably different from other manuals you have seen and it can be very confusing if you try to use it the wrong way Except for the very next section intro this manual is organized to be referred to not to be read You probably won t get very far if you try to read it fram cov
30. a semi colon The concept of error output is not defined in standard CP M so C NIX has introduced the convention that direct console output should be considered error output The actual physical devices associated with the output devices lst con and pun may be adjusted using the normal CP M STAT command such as stat pun up2 Even if paging of output to the console is selected set cmnd the con device will bypass the paging i l4 sa ioredir info Input Output Redirection and Logging ioredir info csh cmnd intro info pipes info quoting info LIMITATIONS In some cases output may appear double spaced when input is redirected This occurs when the program thinks it is reading the keyboard where lines are terminated with the return CR character rather than a file which uses a CF LF pair The program will echo the CR as CR LF and the LF as LF giving two LFs line feeds at the end of each line Programs compiled using C 80 exhibit this problem but since C 80 contains its own I O redirection the problem can be avoided by using lt instead of lt to bypass the Shell and use C 80 s redirection instead The amount of text which may be provided using the parenthesis feature is severely limited All commands are limited to about 250 characters total This limitation can be overcome by creating a separate file with the input for the command 15 patches info NAME patches
31. able file The size of a file is given in kilo bytes The size of a directory is defined to be the space in kilobytes occupied by all files within it or any of its Sub directories The totals given at the end of the listing include the total space occupied by all those files and sub directories listed and the total for the entire disk EXAMPLES ls c asm Display all files in current directory with extension c or 3551 40 15 cmnd ls d d e ls lf help ls t fa ls t bak ls dt NOTES List Directory 15 cmnd Display all sub directories in top level directory of disk D and all sub directories in current directory of disk E Display in long form a list of all files in help sub directory Display the total space in use on drive A Lists the space used by all bak files Lists the space used by all sub directories of the current directory The flags may be combined into a single parameter such as If or t or given separately as l f or t d The 1 and t flag of ls combined with chmod cmnd largely obviate the need for the CP M STAT command SEE ALSO chdir cmd chmod cmd pathname info wildcard info walk cmd Al mkdir cmnd Make and Remove Directories mkdir cmnd NAME mkdir Make and Remove Directories SYNOPSIS mkdir dirl dir2 rmdir dirl dir2 DESCRIPTION The mkdir command creates one or more sub directories The name of the directory must not ha
32. ach disk The current directory is determined by most recent chdir command con that disk ae current directory on the current disk is the current working directory full pathname of the current working directory may be seen with the pwd oman see chdir cmnd If you give a file name without indicating a disk or directory the file is assumed to be in the current working directory You can also give a pathname Starting with a directory name as in the fourth SYNOPSIS form the path will Start from the current working directory For convenience the parent directory of a sub directory may be referred to by the special name allowing pathnames to specify traversing both up and down the hierarchy This is illustrated with the second form under the SYNOPSIS A single dot represents the current directory itself and is particularly useful for the cp cmnd and mv cmnd commands when copying moving a group files into tbe current directory The walk command prints out all the sub directories of the current directory It can also execute a command in each sub directory an operation to be performed on files in various directories SZ 18 pathname info Hierarchical Directory Pathname Syntax pathname info NOTES A sub directory is represented as a file in its enclosing or ent directory with a filename extension of sd where is a letter from 1 to 5 or a to z A total of 31 sub directories may be created on a single disk
33. ages in alphabetical order You should look over the Table of Contents and the introductory page to the Commands chapter to get an idea of what is available and then read the pages that interest you If you are aC programmer you will eventually want to do the same with the Subroutines chapter The individual manual pages are organized to contain as much informatio as possible in a small space You may find them very terse at first but you will get used to the presentation which is designed not only for the printed manual but also for the interactive help cmnd facility in C NIX All the manual pages follow certain layout and typography conventions especially in the SYNOPSIS section which gives a compact but cryptic summary of the command or feature being explained The notation is explained in the manual page for help cmnd PROBLEMS AND COMMENTS If you have problems reading your C NIX distribution disk s contact The Software Toolworks However due to the large number of features in C NIX The Software Toolworks technical support department may not be able to answer all possible questions about using C NIX A limited amount of telephone assistance is available from C Craft during the hours shown below However it would be appreciated if before seeking that assistance you try to exhaust the information provided by the manual including the table of contents index and trouble info section C Craft 22 Downing Road Lexington M
34. ame3 dir 1 d t namel name2 pat3 DESCRIPTION The ls command displays information on files and sub directories within a directory or files which match a wildcard pattern see wildcard info The dir command is a synonym for ls it is provided for compatibility with CP M The ls command alone with no arguments lists the names of all files and sub directories in the current working directory If the l flag long format is given then ls displays the mode and size of each file or sub directory and the total space used by all the listed files and sub directories The f flag lists only files not subdirectories The d flag lists only sub directories Normally both are listed The t flag lists only the total disk Space See examples below In the long format 1 listing ls displays the mode of each file or sub directory Modes are set by chmod cmnd or the CP M stat command and are a set of four flags 1 d for sub directories for files 2 r for all files and sub directories for UNIX compatibility all files are readable under C NIX 3 w for read write files for read only files 4 x for executable files defined to be those with extension com pre or sub s for system files will not appear in short form ls or dir listing for all other files and sub directories For example drw is a typical directory mode r x is the mode for a read only execut
35. arded filenames Only the first file matching the pattern is displayed This limitation exists because when concatenating the order presumably matters and at the moment the shell does not guarantee any specific order for files which all match the same wildcarded pattern Alphabetical order would be consistent with UNIX and could be convenient 26 chdir cmnd Changing Printing Current Working Directory chdir cmnd NAME chdir Changing Printing Current Working Directory SYNOPSIS chdir dir chdir cd dir cd pwd DESCRIPTION The current working directory represents the current focus of activity on C NIX It is like the current logged in disk on CP M Filenames without a disk letter prefix no refer to files within this directory Pathnames which do not start with a slash are relative to this directory relative thnames By default the ls command lists the files and sub directories Ei thin the current working directory A pathname of simply may be used to refer to the current working directory or see LIMITATIONS below The chdir command alias cd changes the current working directory to be some new directory With no parameter the top level directory of the current disk is selected Otherwise the specified directory is selected The disk of this new directory becomes the current disk and its letter is displayed as part of the C NIX prompt After selecting a particular directory on a disk a
36. ating system or to the hardware hopeless a trouble info Redirected program output is double spaced extra blank lines inserted The input of a program cannot be redirected with lt Tabs don t line up properly on 8 column intervals The SAVE command doesn t work The XSUB command doesn t work A spooler like DESPOOL or other background or resident program does not work Hard disk backup procedures do not save all directories Programs intended for a specific CP M implementation will not run DESCRIPTION This section attempts to suggest probable causes for If after considering this list you still cannot see the trouble reporting procedure at the end of the problems while running C NIX solve the problem Trouble Shooting on C NIX trouble info This happens with some programs written in C 80 because they add an extra line feed when writing to what they think is the screen Redirect with N gt instead which uses C 80 s I O redirection Same causes as above During input when output is redirected tabs may echo improperly due to an obscure bug in CP M The tabs will expand properly when viewed later Try the feature instead see ioredir info SAVE is not supported by C NIX Patching must be done under CP M XSUB is not supported by C NIX Use input redirection instead ioredir info These programs poke around in CP M and not all can work with C NIX Th
37. ation if an existing file would be replaced unless the f switch is used see below The first form of my takes two filenames neither of which should contain wildcards The first file is renamed to the second name The second form of mv takes one or more filenames and a directory name The filenames may contain wildcards in which case all matching files will be moved into the specified directory The directory must exist but if it contains any files with the same names as those being moved confirmation will be requested unless the f flag is used The f flag forces the move to a new name or directory without confirmation This may be made the default by patching see patches info in which case c overrides the default and requests confirmation again The vy flag for verbose causes each file name to be echoed as it is moved This may be made the default by patching see patches info in which case q overrides the default and requests quiet mode again The ren command is only legal if the file remains in the same directory It is equivalent to the first form of mv NOTES The mv command is equivalent to cp followed by rm except when the source and destination are in the same directory in which case it is a straight rename The second form of ren is provided for compatibility with CP M SEE ALSO cp cmnd rm cmd patches info pathname info wildcard info 44 rm cand Remove File or Files rm cmd
38. beginning of line Matches end of line Any other character matches itself only The flags n v or c control the matching or printing process n Print line numbers in front of text of line V Output only lines which do NOT match C Upper lower case COUNTS in matches otherwise case is ignored When the c flag is set the characters on the command line are all taken to be lower case Characters which are to be upper case must be preceded by a backslash N For example grep c Nthe paper txt will only display lines with exactly The somewhere within them NOTES The C NIX grep command accepts a slightly different regular expression syntax than that on UNIX systems in particular instead of instead of This is more consistent with C NIX filename wildcards Grep is not a built in shell command The program grep pre may be placed in any directory normally searched 36 grep cmnd Generalized Regular Expression Parser grep cmnd LIMITATIONS Having to backslash upper case for the c flag is a bit baroque Unfortunately to be compatible with CP M upper lower case distinctions must be ignored on command lines 37 help cmd Help From the On Line User s Manual help cmd NAME help Help From the On Line User s Manual SYNOPSIS help help topicl topic2 man man topicl topic2 DESCRIPTION The help command alias man for manual pages displays information drawn from the C NIX Use
39. choing a line feed and returning Nn For getc this means simply ignoring carriage returns because they appear as a pair with newlines in disk files FILES stdio h stdio c fileio c SEE ALSO fopen subr putc subr LIMITATIONS On input to getchar when output is re directed to a file tabs may not be expanded properly This is due to an obscure CP M bug where it loses track of the column position unless a line feed is output to the terminal via console output while getchar must use direct console I O to bypass output redirection Carriage returns without following line feeds in disk files should probably not be ignored by getc so as to allow over printing fopen subr Buffered Pile Opening and Closing fopen subr NAME fopen Buffered File Opening and Closing SYNOPSIS FILE filep filep fopen filename mode fclose filep DESCRIPTION The fopen subroutine attempts to open create the file with the given filename for the given mode either r w a rb wb or ab If successful it returns a pointer to a dynamically allocated see malloc subr FILE buffer structure If not it returns the defined value NOLL The filename must be a normal null terminated C string using CP M filename format of xsname ext The drive letter may be omitted if the current working directory is desired The mode for the fopen is also specified by a string The first letter of the string specifies read only wr
40. cmnd NAME SYNOPSIS bye cat filel file2 outfile cat lt chdir chdir dir chmod w w s s filel cd cp filefrom fileto cp c v q filel dir Summary of C NIX Commands comnands cmnd commands Summary of C NIX Commands Leave the C NIX shell exit Concatenate text files Output text in parens Change to top level directory Change to a new directory Change mode of files Synonym for chdir Copy a file Copy files to new directory csh v q cmndfile paraml Invoke sub shell on command file dir lfdt echo paraml param2 era f filel file2 exit grep pattern filel grep pattern help topicl topic2 hel P ls lfdt patternl pat2 ls lfdt man topicl topic2 man mkdir dirl dir2 mkrel filel00 file200 file pre mv f c oldname newname mv f c v q filel dir pwd ren oldname newname ren newname oldname rm f filel file2 rmdir dirl dir2 set vcbp submit cmndfile paraml type filel file2 walk walk b command paraml NOTES Each of these commands is described within this List directories 15 List current directory 15 Echo parameters to console csh Erase files rm Exit the C NIX shell Search files for a pattern Search console input for a pattern Display help information Display list of
41. commands drive Replace the first temp drive A save 8 b cnixhigh sys Save 8 is 0880 0100 100 hex 2 16 4 patches info Patches to the C NIX System patches info Now test it as follows NOTES A gt b B gt cnix Load C NIX with patched cnixhigh BS echo help foobar Test minimum temp disk letter G foobar BS ls 1 c cat Test that pipes end up on C tw 0 0k pipeda Sure enough BS ls l b cat Test that they are NOT on B Check that commands on D are found B cp grep pre d newgrep pre Copy grep to D BS d newgrep NOTES help intro hlp Should work BS newgrep NOTES help intro hlp Should also work The set command allows some of these patch locations to be changed in memory Modes that can be changed are verbose confirmation and paging The changes last only as long as C NIX is not exited or rebooted At least four temporary drive letters should be provided These are used as logical disks by the shell see pathname info When a commands drive is specified it is searched after the current drive and before the C NIX drive instead of drive A Only the top level directory on the commands drive is searched SEE ALSO csh cmnd cp cmnd help cmnd mv cmnd pathname info set cmnd 17 pathname info Hierarchical Directory Pathname Syntax pathname info NAME pathname Hierarchical Directory Pathname Syntax SYNOPSIS x dirl di
42. e save output in tempfile but also display on console ees you see the complete ls listing B grep rws tempfile run grep to select rws lines eee YOU see just the rws lines B era tempfile and clean up the tempfile You can do this whole process even easier in one step using the C NIX pipe feature The command character will pipe the output of one program into the input of the next So the single command ls 1 grep rws will pipe the output of ls l through grep rws and you will see all the rws lines fram ls l in one step Notes for CP M Users The Rest Most of the other features of C NIX should be familiar to CP M users Submit files can be run by just typing the file name without the submit command so you can run them just like compiled programs Submit files can also call other submit files See COMMAND FILES in csh cmnd As delivered C NIX waits after every 23 lines of screen output for you to type any key This is called paging If you don t like it you can turn it off for everything but the help command see set cmnd or patches info Many of the built in commands have been enhanced to allow a list of arguments instead of just a single file specification For instance the ERA command also called rm see rm onnd may be given more than one pathname or wildcard pathname ambiguous filename in CP M parlance see wildcard info for deletion in a single request A si
43. e a directory listing can go to many screenfuls With hierarchical directories instead of having all of the files in a single directory you can create a subdirectory and put a group of files into it say all the files you need for a particular project Directories are created using the command mkdir Having a subdirectory is something like using a separate disk drive to hold just those files except that instead of drive letters subdirectories have names and the files in several subdirectories can go on the same disk When you doa directory listing in the main directory all you seg is the subdirectory name not the files it contains If you want to further organize the files in the subdirectory you can create sub subdirectories within it and so on In this way you get a tree structure of directories on the disk where the top level directory is the trunk each subdirectory is a branch The top level directory of a disk is always named by a slash and the disk letter For example the top level directory of disk A is always called a When you first run C NIX you are in the top level directory of the disk with C NIX on it usually a To see that you can type the command pwd for print working directory which will show the current directory name In CP M if you organize your files on different drives you can move over to other drives by typing for example B Similarly you can move to different directories To move to the d
44. ed to use another disk see patches info Because all of the output of one command must be collected before the next can be run the pipe file disk must be writable and have enough room to hold the data The C NIX shell names the temporary pipe files x pipe0 9 9 where x is the pipes disk and is a character from a to z The files are automatically SEE ALSO ioredir info patches info grep cmnd 20 quoting info Quoting and Escape Characters quoting info NAME quoting Quoting and Escape Characters SYNOPSIS DESCRIPTION Various characters have special significance in C NIX commands In particular at various times the following characters are interpreted specially 2 lt gt N SPACE lt RETURN gt If you want to use one of these characters in a command you may need to slip it past the C NIX shell to let the program see it To do this you must te the character You can quote a single character by prefixing it with the kslash X character Alternatively a string of characters may be quoted with matching apostrophes or double quotes A common problem occurs with CP M commands which take switches containing the character on the command line The error message Bad directory may be given To avoid this enclose the entire argument in quotes Within quotes or parentheses some but not all of the above characters lose their significance In particular within single quotes apostrophe
45. er to cover The way to use it is to go looking for specific information In order to do that you need a general idea of what information it contains and you need to know how to find that information C NIX contains three kinds of enhancements to your CP M system These are features which you can use in most CP M commands new commands to perform some new functions and subroutines which are only of use to C programmers The C NIX User s Manual is organized into three Chapters each dealing with one kind of enhancement General Information info which describes the features C NIX Commands cmnd and C NIX Subroutines subr In this manual when one of the enhancements is mentioned by name you will usually see also the manual chapter in which it can be found for example help cmnd Each chapter consists of entries called pages each explaining one command or feature A manual page can in fact take up several screenfuls or paper pages but it s still called a page Pages are in alphabetical order within each chapter eode WHERE TO BEGIN READING You should begin by reading the remainder of this section Then read the first info page Introduction to C NIX Features and browse through the rest of the info chapter to get an idea of what features are available In each of the other two chapters there is a general introduction page which gives a bit of a roadmap to that chapter s highlights followed by the remaining p
46. fter exiting the user is returned to the directory that was current at the time the shell was invoked NOTES The bye command is synonymous with exit under C NIX An end of file will also cause the shell to exit i e the end of a command file or control Z from the console SEE ALSO csh cmd grep cmnd Generalized Regular Expression Parser grep cmd NAME grep Generalized Regular Expression Parser SYNOPSIS grep nvc pattern filel file2 grep nvc pattern Patterns have the general forms tabo j m 5 Xyz abcde abcdeS DESCRIPTION The grep command is based on an old favorite from UNIX systems The grep command searches a list of files or the console input for lines which contain a text string or which match a pattern Normally the matching lines fram the file are displayed on the console although there are other options A pattern can be simply a text string In this case grep just outputs all lines containing that string A more complicated and general search can be done using a pattern which is a regular expression This is something like using wildcards and in file names see wildcard info but more complex In a grep pattern Matches any single character Matches zero or more arbitrary characters abc Matches any one of characters in brackets a m Matches any character in the given range qz Matches any character but those following T Matches
47. ile routines v 0 90 099900 900 00060900299 9 51 file search e 9 v 0 9 9 0 0 90 006 0 00090090909 909909 28 file sizes display vw o 00906 90 09909090099 40 file copying w 9 0 9 0906 990 0 0 000 090000909 29 file copying to existing 29 file erasing vw 9 0 0 09 06 00 9 9 909 0060290900 9 45 file invisible 9998949499 98988 9 9999 28 file renaming w 90690906 090990 99 00 29 9929909 44 filenames 9 99 9 99 9 18 24 files batch 99 06 9 0909 99 90 0 0099909 09 30 files command cccccccccccccccce 30 files concatenating 9 26 files missing 9 9 9 9 22 files searching 9999899 36 files showing 9 9 0 6 9 20 files submit eeeengeaeneoooeooeoeoeoneoneoen ees 30 filters 9009009 060 00 0 20 finding a file w 000 090990 9 9009 09 0290090 28 first use vw 99v09 09 0 0 0 00 0 00 00009009 9 09009 9 8 flag read only 9 9 9999 9 98 28 flag SYS 09906 60 0 0 0 9 90 9 9 9 90 0 9 099 06 0209090 28 flag writeable 28 flags file 0 0 28 fopen 9 9 99 9 99996994 9
48. interest on the various disks with chdir and using the X notation or by patching cnixhigh sys to allow more temporary disks see patches info Explicit use of the user feature of CP M is not supported There is no user command and use of Gnn in PIP or the setuser BDOS system call is ignored 13 pipes info C NIX Pipes pipes info NAME pipes C NIX Pipes SYNOPSIS commandl paraml command2 param2 command3 DESCRIPTION Pipes allow several programs to be run in succession with the output fram one program being passed to the next program as its input Pipes are convenient when the output of a command should be sorted or reformatted in some way before being saved permanently in a file Programs designed to do this kind of sorting or reformatting are called filters C NIX uses the vertical bar to separate commands in a pipe EXAMPLE asm foobar grep error This example assembles foobar and then passes the output through the filter grep which outputs only the lines of its input which contain the string error somewhere within them NOTES Because CP M is not a multi tasking system only one of the commands actually runs at a time All of its console output is collected in a temporary pipe file and then the next command in sequence is run with its console input redirected to come from this temporary file Normally the pipe files are created on the C NIX disk but C NIX can be patch
49. irectory help type chdir help Chdir means change directory TO see the name of the new current directory type pwd This will display the name a help a help is an example of a pa which is a way to refer to files or directories that might not be in the current directory A pathname is just a list of subdirectories separated by slashes The path may start with a slash and a disk letter which means it starts in the top level directory of a diskette If it does not start with a slash it starts from the current directory For example d sources compiler parser c might be the full pathname for a file named parser c The subdirectory 10 intro info Introduction to C NIX Features intro info sources is in the top level directory of disk D The subdirectory compiler is within sources and the file parser c is within compiler If a directory listing is requested for the top level directory of disk D only the subdirectory sources will appear Compiler and parser c will only appear when a directory listing is requested of their respective parent directories d sources and d sources compiler You can use full pathnames in all C NIX commands where a filename is required For example instead of changing directories to type the file parser c as in BS chdir d sources compiler D type parser c E chdir b you could simply say B type d sources compiler parser c Even if you are not in the top level directory you stil
50. is given in parentheses after its description NOTES I These routines follow the C 80 machine language calling conventions as follows Arguments are pushed onto the stack as 16 bit values leftmost argument first If a function returns a value it is in the HL register The calling routine is responsible for popping arguments back off the stack No registers are preserved bdos subr C Interface to BDOS Calls bdos subr NAME bdos C Interface to BDOS Calls SYNOPSIS x bdos code arg DESCRIPTION This subroutine loads code into the C register arg into the DE register and then calls BDOS via low memory jump vector at 5 6 7 The BDOS return value comes back as the function return value This gives the C programmer direct access to all of the BDOS interfaces A complete set of C preprocessor definitions are provided in a file bdos h on the C NIX source distribution disk The actual code is in bdos c written assuming the Software Toolworks C 80 calling conventions NOTES When running with C NIX the jump vector at 5 6 7 has been altered to point to the cnixhigh sys interface module This is transparent to the programmer Bdos is provided for compatibility with C 80 2 0 and earlier It is included with C 80 3 0 and later FILES bdos h bdos c AQ getc subr Standard Buffered Character Input getc subr NAME getc Standard Buffered Character Input SYNOPSIS FILE filep c getc filep s
51. ite only or append only The second letter if b specifies a binary file so embedded control z text end of file characters are ignored and no other translations are performed Once opened the returned FILE pointer can be passed to gete if open for r or rb or putc fprintf if open for w wb a or ab When processing is complete the FILE pointer should be closed with fclose thereby writing to disk any partial buffer full and releasing storage reserved for the internal FILE buffer structure When opening for write only the file is created It must not already exist When opening for append only the file may exist but it will be created if necessary FILES stdio h fileio c fopen c SEE ALSO getc subr malloc subr putc subr LIMITATIONS It might be convenient to provide a mode which would allow overwriting an existing file Bj main subr Hidden Main Routine Exit Routine main subr NAME main Hidden Main Routine Exit Routine SYNOPSIS c main main argc argv char argv exit exit status DESCRIPTION The routines c main and exit are provided in the file cmain c c main is where execution should actually begin for all C programs It builds an argument list following the UNIX conventions and then calls the user provided main routine with an argument count argc and a pointer to an array of string pointers argv The arguments are constructed from the information in the CP M
52. ith the same names as those being copied confirmation will be requested The f flag forces copy without confirmation This can be made the default by patching cnixhigh sys see patches info in which case c overrides the default and requests confirmation again The v flag for verbose causes each file name to be echoed as it is copied This may be made the default by patching cnixhigh sys see patches info in which case q overrides the default and requests quiet mode again The source files are unaltered To rename a file or move it to another directory see mv cmd SEE ALSO mv cmd rm cmnd patches info pathname info wildcard info _ 29 csh cmnd The C NIX tm Shell csh cmnd NAME csh The C NIX tm Shell Command Formats SYNOPSIS B cnix csh csh v q cmndfile paraml param2 param3 cmndfile paraml param2 param3 commandl paramil paraml2 command2 param2l DESCRIPTION The C NIX shell is the program which displays the command prompt for example A reads the commands you type and executes them It also executes commands files also called batch or submit files The CP M equivalent is called the CCP Our discussion of the shell breaks down into two topics how to invoke the shell and what features and commands the shell provides Normally you won t need to invoke the shell at all since it comes up automatically when C NIX is entered or when you run a comma
53. ively The letter s following the or determine which modes are changed The changes made by the set command will be in effect only until C NIX is exited or the system is rebooted The v flag sets the verbose mode If this mode is on commands such as cp m rm and set itself tell you what they are doing as they do it When verbose mode is off the default the commands just execute without any messages In addition with verbose mode off command files submit or shell files do not echo the commands in the file with verbose mode on they do echo The p flag determines whether output to the console is paged or not In paged mode whenever 23 lines are output without any typed input C NIX pauses and waits for any character to be typed before proceeding This always happens in the help command whether paged mode is on or off In paged mode a character can be output to alert you to the need to type a key to proceed The b switch will cause a bell to be output The switch will cause a to be output Turning either of these switches off will cause no character to be output The c flag determines whether confirmation is requested by the rm mv and cp commands when a problem is encountered When confirmation mode is on the default these programs will not copy over an existing file without requesting confirmation You can type four letters when confirmation is requested y yes remove the file n no don t remove the fi
54. k in drive B by the one marked Disk 2 and again type the command AS cp b hlp help If you have three distribution disks repeat this step for Disk 3 as well Advanced Installation Notes This section describes some installation features for the more advanced user If this is your first time through this manual you may want to skip this section for now Many versions of CP M allow you to install a command which is executed automatically on cold boot when you boot up Often the program which allows you to specify this command is called CONFIG or CONFIGUR or something like that consult your CP M user s manual for details If your CP M provides that facility you can set it to execute the CNIX command automatically so that you always enter CNIX when you boot up When C NIX begins executing it looks for a file named cnixinit sub If this file is found it is executed as a submit file This allows you to execute one or more commands automatically whenever you enter C NIX If you are a C programmer you may wish to copy the C program sources and the mkrel command from the distribution disk s onto your system disk for later use The files to copy are mkrel com c and h If there is more than one distribution disk the files may be split among the disks You may want to use mkdir cmnd to create a subdirectory for the source files If space is a problem on your system you may want to install all the C NIX files m a disk drive other
55. ked Disk 1 We will assume that drive is B but if your System uses a different drive letter then use that letter instead of B throughout this procedure Type the command A gt pip a b cnix The names of the three files being copied will print out When the A gt prompt reappears type A gt cnix You should now see something like C NIX IM SHELL 1 56 12 Jan 85 Copyright C 1985 C Craft IM Lexington MA AS C NIX is awaiting your command You will now copy some of the other C NIX files onto your system disk depending on how much space you have on your system disk and which features of C NIX you are likely to want to use The files you will copy have to do with The grep comard is useful for searching for a word or text string in files The set conmand lets you alter some system parameters To install them type the command AS cp b grep pre b set com The b in this command is the drive letter for the C NIX disk so if your System calls it by a different letter use that letter instead A powerful feature of C NIX is the help or man command which can bring up on the screen any of the information pages contained in this manual To install the manual page files you will need about 114K of free space on your system disk Type the commands AS mkdir help AS cp b hlp help intro info Introduction to C NIX Features intro info If your C NIX system came on more than one distribution disk replace the dis
56. l have access to files and commands stored there See The Rest below for more details See also the manual pages for pathname info chdir cmnd and mkdir cmnd for more information on hierarchical directories The walk command lets you display all the subdirectories in any directory It can also perform an operation in each subdirectory See walk cmnd Notes for CP M Users I O Redirection and Pipes Another important UNIX like feature of C NIX is I O redirection Normally many commands or programs simply put their output on the console The ls or dir command is one example I O redirection lets you redirect the output of a command or program into a disk file Or you can provide the input for the program from a file instead of from the keyboard see ioredir info You can also feed or pipe the console output of one program back in as the console input for another program see pipes info For example suppose you want to list all the files in the current directory T the SYS flag set The ls 1 command will list these files with the rws ags rws 13 2k clibrary rel for example So you want to see just those lines in the output of the 15 l command which have the string rws in them With C NIX you can redirect the output of the ls command to a file Then you can use the grep command to show you the lines containing the string rws intro info Introduction to C NIX Features intro info l B ls l gt tempfil
57. le f fast remove the file and stop asking X exit don t remove the file and quit now NOTES All these modes can be set permanently by patching the system See patches info If you want to change the modes fram the default but don t want to patch the system you can invoke the set command in cnixinit sub see intro info SEE ALSO csh cmd patches info 46 walk cmnd Walk the Directory Tree walk cmnd NAME walk Walk the Directory Tree SYNOPSIS b walk b command argl walk b command arg command arg DESCRIPTION The walk command walks the directory tree starting at the current working directory That is it goes to the current directory and all of its subdirectories sub subdirectories etc In each directory it performs an action depending on the form of the walk command used The order in which the directories are taken is either top down the default or bottom up b flag Walk with no arguments simply echoes the full pathnames of all directories If followed by a command or parenthesized command list after echoing the directory pathname walk executes the command list Any wildcard specifications are re evaluated for each command list execution However pathnames with slashes in them are always interpreted relative to the starting directory For example to delete all files with the extension bak in the current CEE Sey and all its subdirecto
58. ls subr NAME strutils Standard String Utilities SYNOPSIS if strany c str if stremp strl str2 gt 0 cp strcpy to from if streql strl str2 1 strlen len mvbytes from to num DESCRIPTION These routines provide standard means for manipulating null terminated strings in C All but mvbytes are based on the UNIX equivalents Strany returns non zero if the given character appears anywhere within the given string Stremp returns greater than zero equal to zero or less than zero according to whether strl is later the same or earlier lexicographically than str2 Lexicographic order means that if one is a prefix of the other then it is considered earlier or less When the strings are alphabetic only the order is simply conventional alphabetical order Strcpy copies characters up to and including the null terminator from its second argument from to a buffer area pointed to by its first argument to The buffer must be long enough to hold the copied string Strcpy returns a pointer to the null at the end of the copy allowing a cascading series of strcpys to do concatenation as follows Concatenate first and second into buf strcpy strcpy buf first second Streql returns non zero if strl and str2 are identical strings Strlen returns the length of str not counting the null terminator copies num bytes from an area from to an area to Mvbytes does NOT stop at null te
59. mple on line documentation mechanism the help command has been built into the C NIX shell command processor providing pages from this manual on demand See help cmnd If you are in a subdirectory you still have access automatically to commands which are in the top level directory of the current disk disk A or the disk from which C NIX was initially run So you will want to put all your frequently used command files in probably the top level directory of disk A Also if a running program looks for a disk file which is not in the current directory it will find the file of the same name in any of these top level directories if the SYS attribute of the file is set see chmod cmnd So you can keep library files and other common non command files in one place too SEE ALSO For more information on the features of C NIX you can browse through the other pages of this manual In particular see help cmnd conmands cmnd csh cmnd ioredir info pathname info pipes info walk cmd wildcard info 159 ioredir info Input Output Redirection and Logging ioredir info NAME ioredir Input Output Redirection and Logging command paraml param2 gt outfile command paraml param2 gt gt outfile command paraml param2 infile command paraml param2 gt logfile command paraml param2 infile command paraml param2 gt amp out and errorfile command paraml param2 licit inp
60. n 9999 44 Il coss 4e rmdir 9 999499 0 9 42 Set 46 type See cat cmd 999 9 9 9 25 commands over subdirectories 47 commands grouping 30 comments to author w o9 90 069 9 9 9 999929 09 4 compress subroutine 9999999999 48 53 concatenating files 26 conditionals how to do 32 confirm required changing 16 console paging 990 0690 9 06 06 99 90 09090290990 46 copying a file 29 copying between directories 29 copying to existing file 29 cp command eee o 25 29 csh command 25 30 current directory 18 current working directory 27 H c main subroutine v 09 9099 9999909299 52 defaults changing 16 delete a file 9999894 9 9 9 9 9 9 45 description 999949 899 89 9 9 9 99 99999469 38 DESPOOL w 00 0 090009 0 09 0 00 0909099 0 0902992099 23 dir command 25 40 directories copying between 29 directories hierarchical 10 directories implementation of 42 directory listing 40 directory sizes display 40 directory structure
61. namic Memory Allocation and Release malloc subr NAME malloc Dynamic Memory Allocation and Release SYNOPSIS struct my_rec ptr ptr malloc sizeof struct my rec free ptr mp compress DESCRIPTION These routines provide for dynamic memory allocation and release for arbitrary sized C structures or arrays The malloc routine takes a size in bytes and returns a pointer to the start address of an allocated area When done with the area the space can be released with free If malloc cannot allocate sufficient space without running into the C stack it will print an error message and return a NULL pointer The compress routine attempts to compress the heap from which malloc allocates areas and then returns a pointer to a structure describing the heap allowing it to be saved en masse see malloc h NOTES x Returning an area to free which was not allocated with malloc is disastrous The area allocated is NOT initialized to zeros Malloc uses a word in front of each area to indicate its length as well as whether it is free or in use These allow malloc to iterate through all areas and locate a large enough contiguous free chunk It is designed to be particularly efficient if memory is used approximately in a last allocated first freed order pute subr Standard Buffered Character Output putc subr NAME putc Standard Buffered Character Output SYNOPSIS FILE filep putc c filep
62. nd file So first time users may want to skip to the next heading now The C NIX shell may be initiated in several different ways as illustrated by the various forms under SYNOPSIS above The first SYNOPSIS form shows how the shell is first invoked as part of C NIX initialization The disk on which cnix com cnixhigh sys cnixutil pre and help sda all reside MUST be the current disk when cnix is first invoked or else it will immediately exit The second form csh invokes a sub shell In effect this places the current shell aside and drops down into a new one Exiting the new sub shell 566 exit cmnd returns to the old shell This is useful for wandering off temporarily to various other directories since exiting returns to the original directory This form is also useful when a list of shell commands are constructed by some program and then piped into the shell see pipes info In the third form the shell is run with the name of a conmand sub file from which it is to take commands to be executed The remaining parameters in the command replace occurrences of 1 2 etc in the command file The optional flag verbose or verify causes commands from cmdfile to be echoed before execution This can be made the default by patching cnixhigh sys see patches info in which case the q flag may be given to request quiet mode again See Command Files below for more details Command files can also be executed simply by typing
63. ontrol returns more quickly to the shell after the execution of a page relocatable program because the shell need not be reloaded from disk The format produced by mkrel is based on the format produced by the PREL rogram delivered with Heath CP M 80 systems Programs built with mkrel have a Length in their second and third bytes the code starting at the 257th byte and a map of relocation bits at the end There is one relocation bit for every byte of code If the bit is off the corresponding byte is to be loaded unchanged If the bit is on the corresponding byte and its preceding ome are adjusted by the address where loading started It is normal for programs linked with certain linkers e g Microsoft s L80 to have random values in uninitialized data areas This will cause mkrel to complain about bytes differing by more than 1 in those sections of the files As long as this only occurs in uninitialized data areas the resulting pre file will still load and execute properly SEE ALSO csh cmd LIMITATIONS A more compact format would be possible 43 my cmnd Move a File or Files nv cmd NAME mv Move a File or Files SYNOPSIS mv f c oldname newname my c v q filel file2 file3 dir ren oldname newname ren newnamesoldname DESCRIPTION The mv command moves renames a file to have a new name or moves a set of files to another directory keeping the same file names Mv will ask for confirm
64. ooo o 9 9 999 38 synopsis eeeoeocoly on oooooooeooo ooo ooo 38 SYS flag 9 9 99 0 9 28 sys flag required changing 16 system call tabs problems with 23 top level directory 10 18 top down cccccccccccccccccccccscce 47 trouble 22 type command see cat cmnd e 0 90 0909000 006 00060 99 49 UNIX like features 6 6 6 6 666 6 6 666 10 user number changing maximum 16 user numberS 42 using manual 3 verbose flags changing 16 verbose mode setting 46 walk command ll 18 25 47 walking directory tree 47 wildcard 7 24 working directory 18 27 write protection 28 writeable flag 2e e ee 28 XSUB not supported 14 23
65. ories reducing the number available It is not meaningful to attempt to make or remove a top level directory like d Mkdir and rmdir are implemented by the special relocatable program cnixutil pre on the C NIX disk SEE ALSO rm cmnd pathname info LIMITATIONS The 31 sub directory maximum could be a troublesome limit for some very large disks Unfortunately this limitation cannot be easily removed while remaining compatible with CP M Maybe it s time to step up to that 32 bit supermicro 42 mkrel cmd Make Page Relocatable Program mkrel cmnd NAME mkrel Make Page Relocatable Program SYNOPSIS mkrel basel00 com base200 com progm pre DESCRIPTION The mkrel command creates a version of a program called a page relocatable program which can be loaded and executed without removing the C NIX shell from memory This makes the program run faster and is useful for small frequently used commands Mkrel compares two com format files to form a page relocatable program with the extension pre The first file must begin at 100 hex and the second at 200 hex Such files are usually created by assembling the same program twice with different ORG statements at the beginning A page relocatable program can be run by the C NIX shell and will load above the end of the shell instead of replacing it i NOTES Because page relocatable programs are loaded above the shell they have significantly less memory available C
66. ose that can like DESPOOL must be loaded BEFORE C NIX is run C NIX uses user numbers 1 to 3l Some backup procedures may not save user numbers over 15 directories sdk and above Use cp to copy files to disk instead or patch C NIX not to use user numbers over 15 patches info Certain programs e g versions of Micro soft BASIC for some Heath Zenith machines refuse to run on other operating systems These programs may not recognize C NIX as a legal system Exit from C NIX to run the program anticipated Introduction to the printed C NIX manual SEE ALSO patches info LIMITATIONS Some of the limitations implied in the probable causes above should be removed from C NIX or CP M wildcard info Filename Wildcards and wildcard info NAME wildcard Filename Wildcards and SYNOPSIS matches any single character of a filename matches any number of characters at the end of the name part or the extension part of a filename DESCRIPTION Wildcards are characters and used in filenames in commands in order to refer to a set of files with similar names instead of a single file C NIX supports almost the same wildcard conventions as CP M CP M documentation refers to a filename pattern containing or as an ambiguous file name afn In C NIX and are called wildcards and the ilename is wildcarded As in CP M a takes the place of any character within the 8 character name
67. pes info and hierarchical pathnames pathname info A quick summary of all of the C NIX commands can be found in commands cmnd The notation used in the command summary SYNOPSIS on most manual pages is explained in help cmnd NOTES The diskette from which cnix com is run must remain on the same drive throughout use of C NIX The command interpreter or Shell always looks to the top level directory of this drive to reload itself between program executions as well as for the help sub directory and the program cnixutil pre which contains the commands chmod mkdir and rmdir The file cnixhigh sys is loaded into high memory when C NIX first starts and then remains resident a intro info Introduction to C NIX Features intro info until C NIX exits NOTES FOR CP M USERS The C NIX interface is modelled closely after UNIX Many UNIX features like hierarchical directories pipes and I O redirection are also used in MSDOS 2 0 and higher A understanding of either of these systems preferably UNIX will help greatly in making use of C NIX This section provides a quick introduction to the UNIX like features of C NIX Any of the several books om UNIX would also be a help Notes for CP M Users Hierarchical Directories Probably the most important UNIX like feature of C NIX is the hierarchical directory system This is especially useful in helping you organize your files con a hard disk other large capacity disk wher
68. r s Manual The available information is organized into topics or equivalently pages just like the printed manual Help with no arguments shows the list of topics Help with a list of topics displays the information for each topic on the console one after the other The information is displayed 23 lines at a time After displaying 23 lines the computer waits for any key to be typed before continuing Each manual page is organized into the following sections NAME Name and descriptive title of manual page SYNOPSIS A short summary of how to use the feature DESCRIPTION A discussion of the topic command or subroutine EXAMPLES Examples as appropriate NOTES Interesting side issues SEE ALSO Other manual pages of interest LIMITATIONS Existing limitations or possible enhancements The SYNOPSIS section gives brief possibly cryptic examples of how to use the command or feature Throughout the manual page but especially in this section a special notation is used to describe variations and optional command fields Anything in square brackets like this is optional and may be omitted Example rm f file means you can type either rm file or rm f file the f is optional The symbol means any number of the preceding object may be used Example mkdir file means you can have any number of file names after mkdir but at least one The symbol means either the symbol on the left or the one on the
69. r2 name ext dirl dir2 name ext x dirl dir2 name ext dirl dir2 name ext DESCRIPTION C NIX supports a tree like hierarchical directory structure Each disk may have sub directories along with files and each sub directory may have further sub directories and files This feature allows each directory to remain smaller containing a logically related set of programs and data Files and directories in various directories are referred to by pathnames The top level directory of each disk has a pathname of the form x where x is the disk letter Each file or sub directory in the top level directory has the pathname x followed by the file or directory name For example if the top level directory of disk a contains a directory help the pathname of that directory is a help Once you have constructed the pathname of any directory the pathname of any file or sub directory within it is the pathname of the directory followed by a Slash and then the name of the file or sub directory So the file mv tin in the help directory of the preceding example has the complete pathname a belp mv tin CP M already has the concept of the current disk or logged in disk The letter of the current disk appears in the command prompt for example A gt on CP M or AS on C NIX If you give a file name without a disk letter that is file as opposed to b file the current disk is assumed In C NIX there is also a current directo on e
70. ries use cautiously the command walk rm f bak The default order of walking is top down which in a directory tree means the current working directory first the the first sub directory then the first sub directory of the first sub directory etc The b flag requests that the walk be done bottom up K 55 n um way out to a leaf sub directory one with no further sub directories doing a directory only after all its sub sub directories NOTES A simple way to determine the size of each directory con a drive is chdir x walk ls ft which will change to the top level directory of the specified drive and then display a file size total for each directory in the walk SEE ALSO pathname info wildcard info ls cmnd subrs subr C Subroutines for C NIX subrs subr NAME subrs C Subroutines for C NIX SYNOPSIS bdos code arg Call BDOS with code in C arg in DE fopen fname mode Open a file return a FILE pointer fopen fclose file Close a given FILE pointer fopen getc file Get a character given a FILE pointer getc getchar Get a character from the console getc main Hidden main routine expands wildcards etc main malloc size Dynamically allocate memory chunk malloc free ptr Free allocated memory chunk malloc compress Compress dynamic allocation heap malloc putc c file Put a character given a FIIE pointer putc putchar c P
71. right may be used Example chmod w w s s file means you can say chmod w file or chmod w file etc Sometimes you can use more than one of the alternatives sometimes only one makes sense Switches are special arguments to commands Following the UNIX convention Switches are a minus sign followed by one or more letters When several letters are shown usually any one or more can appear in one or more switches Example grep nvc pattern means you can follow grep with n v c W c v etc NOTES The display of help topics shows them with their filename extensions ehlp There is no need to type this extension when requesting help on a topic In order to save space on the distribution disk the help file for intro info 39 lt help cmnd Help From the On Line User s Manual help cmnd has been edited The printed manual page contains more information You can add your own help files by making text files giving them the appropriate name with the hlp extension and putting them in the help directory If space is a problem you may place the help files on a disk other than the one containing C NIX by patching cnixhigh sys see patches info SEE ALSO intro info patches info LIMITATIONS The information could be more efficiently encoded on the disk instead of one topic per file ls cmd List Directory ls cmnd NAME ls List Directory SYNOPSIS ls 1 d t namel pat2 n
72. rminators NOTES The strcpy routine familiar from UNIX returns a pointer to the BEGINNING of the copy not the end as it does here The order of parameters for strcpy and mvbytes are the opposite of one another FILES strutils c er Index notation 0 99 9 09 18 ee notation 9 09 99 0 0 0 18 999 notation 9 99 990 9099696 38 switches 9999 99 21 notation 999894 8 38 notation 9 9 9999 99 0 0 969 0 0 38 aborting command file 33 ambiguous file name 24 arguments limits on 0 33 autostart command 999999 9 9 4 99 8 backup problems with 23 bad directory message 21 batch files 9 9 9 30 bdos subroutine eeeeeeaeeoeoeoeeod 48 49 begin how to 9 ooo ooo 4 bottom up 0 909006 0 0 9 9990900 9 909 99 0900909 47 bye command 9 25 35 C character output routines 54 C character read routines 50 C file routines 51 C main program eeeooooooooooo 52 C memory allocation routines 53 c source files 8 C string functions 99999 0 909 099996299 9 55 C system call 9099990909000
73. s all but backslash RETURN and single quote itself lose their significance Within double quotes RETURN dollar sign backslash and double quote itself are still significant 3 Parentheses defer the processing of all but dollar sign Thus commands within comand files may be given multi line input which depends on the parameters to the command files EXAMPLES 180 fco clibrary fooV nV e characters must be quoted ddt s 1 20 21 execute ddt substitute at address 591 22 specified as first parameter to command e file 0 grep and or thesis txt Slash and space must be quoted NOTES The amount of text which may be included within quotes is limited to a single line The amount of text which may be enclosed within matching parentheses is limited to about 250 characters SEE ALSO ioredir info trouble info NAME Trouble Shooting on C NIX trouble info trouble Trouble Shooting on C NIX SYNOPSIS Problem A command containing special characters such as or V does not work or gives error messages The shell immediately exits after it is invoked with cnix C NIX exits instead of returning with a shell prompt The shell is slow in prampting after a program finishes Files seem to be missing from the directory A file cannot be moved or removed Pipes don t work or the disk fills up during a piped command The output of a program cannot
74. s the current directory it continues to be accessible using simply the disk letter prefix x instead of its full pathname until a new directory is selected to be current for THAT disk Thus at any one time C NIX keeps track of a current directory for every disk The one for the current disk is considered the current working directory The pwd command displays the full pathname of the current working directory and is handy to answer the question Where am I LIMITATIONS The only C NIX commands that know about and are ones such as rm cmnd and cp comnd which deal with directories For other commands e g echo cmnd and non C NIX programs which want a drive name as argument e g A it may be necessary to use and as pathnames in order to force the shell to provide the correct equivalent The shell recognizes only pathnames containing the character SEE ALSO csh cmnd mkdir cmd pathname info chmod cmnd Change File Mode Flags chmod cmnd NAME chmod Change File Mode Flags SYNOPSIS chmod w filel file2 chmod w filel file2 chmod s filel file2 chmod s filel file2 chmod ws ws s w w s filel file2 DESCRIPTION The chmod conmand allows the user to change the file mode flags of a file Each C NIX file has two mode flags a writeable flag and a SYS flag When files are created they are by default writeable However this flag may be cleared after
75. the current working directory the top level directory of the current drive the top level directory of drive A and finally the top level directory of the drive from which C NIX itself was loaded A commands drive may be substituted for A in this search path by patching cnixhigh sys see patches info If the SYS bit required flag is set in cnixhigh sys see patches info then only commands with the SYS bit set see chmod cmnd will be found in the top level directory of the current drive This provides compatibility with CP M 3 0 Note that when a program tries to open a file during execution the top level directory is also searched automatically but the SYS bit is always required in that case Certain comnand names are built into the C NIX shell These commands are either implemented within the shell itself for example cp mv 1s or are implemented by a special utility program called cnixutil pre currently only chmod mkdir and rmdir These commands will start and finish more quickly because they are built in to the shell or are in a known directory and the shell does not have to be reloaded after they finish Bye and exit are two names for the built in command which makes the shell finish execution and return to CP M if a top level shell or return to the invoking shell if a sub shell End of file on a command file will also cause the shell to exit Several C NIX commands may be entered on the same line by separa
76. ting them with a semi colon Alternatively you may use several lines to type a single command by typing a back slash immediately before the RETURN key see quoting info The shell also provides for input and output redirection and logging see loredir info as well as the connection of two or more commands with C NIX pipes see pipes info COMMAND FILES As mentioned above the C NIX shell supports command files When the command file is run each line from the file is read and executed by the shell substituting the actual parameters for 1 2 etc This is just like the CP M SUBMIT command but you don t have to type the word SUBMIT just the name of the command or submit file csh cmnd The C NIX tm Shell csh cmnd Unlike the CP M SUBMIT command command files in C NIX don t display the commands on the screen You can run the shell explicitly with the v verbose flag to make echoing happen csh y cnndfile paraml or patch cnixhigh sys to make verbose the default mode see patches info Unless redirected commands within command files receive their console input and output from the same place as when the sub shell was invoked This allows command files to act as normal programs interacting with the user at the terminal or as a filter in a pipeline For convenience when a command is to be run with predefined input the text may be included as part of the command file by enclosing it in parentheses
77. truct gc buf rec getbuf getbuf g max sizeof getbuf g data set gcbp amp getbuf getchar DESCRIPTION These two get routines provide standardized buffered character input Getc expects an opened FILE pointer see fopen subr or one of the two standard file pointers stdin or stderr Getc stdin reads from the console using getchar see below Getc stderr reads from the console using the direct console I O BDOS call bypassing any C NIX input re direction Getchar reads from the normal console input which may have been re directed from a file by the C NIX shell If a previous call to set gcbp has been done then getchar uses the read console buffer BDOS call Otherwise it uses the single character console input BDOS call In either case each call returns the next input character returning the defined value BOF when end of file or control z is reached see the file stdio h Set gcbp sets up a console buffer for getchar The buffer must be of the form defined in stdio h which is based on the console buffer required by the read console buffer BDOS call The field g max must be initialized to the length of the data area as shown in the SYNOPSIS above NOTES Unless in binary mode see fopen subr none of the get routines return the carriage return character Nr but instead return a single C newline Nn to represent end of line For getchar this means interpreting a carriage return as end of line e
78. ut command paraml param2 gt amp gt amp gt gt amp out log err command paraml param2 gt gt gt amp gt amp out log err C NIX lets you redirect the console input or output of a command That is what would normally appear on the screen can be saved on a file instead or in addition Also instead of taking typed input from the keyboard the program can be made to take it fram a file C NIX also lets you save the keyboard input on the output file Finally it allows C NIX error messages output using the BDOS direct console output primitive to be redirected with the normal output The first SYNOPSIS form gt is the simple case of output redirection In this Case Output which would have appeared on the terminal is instead saved in the specified outfile Outfile must be the name of an output device or a new disk file the shell will complain if it is an existing disk file except see below Legal output devices are as follows lst The listing device The console ensures output goes to console even if some enclosing redirection is in force bypasses console output paging if in effect pun The punch device The error device namely Direct Console Output bypassing BDOS processing nul The Bit Bucket output discarded The second SYNOPSIS form uses gt gt which means add the output to the end of the Outfile if it already exists If the file does not exist
79. ut a character on the console putc fflush file Flush output for given FILE pointer putc strany c str Return non zero if char within str strutils strcmp strl str2 Return lt 0 0 gt 0 after comparing strs strutils strcpy to rom Copy string return ptr to end of to strutils streql strl str2 Return non zero if strs identical strutils strlen str Return length of string strutils mvbytes from to num Copy bytes strutils DESCRIPTION This subr chapter describes C subroutines written to work with C NIX Most of these routines will also work with normal CP M systems IMPORTANT CAUTION The routines have only been tested with the C 80 2 0 compiler from Software Toolworks Sherman Oaks California Some of them replace routines included with that compiler in a way that is more directly compatible with the UNIX standard subroutine libraries Equivalents for some of these routines are included with later C 80 versions Using these routines with any particular C compiler including C 80 may require replacing or removing parts of the I O library provided with the compiler or renaming functions in order to remove name conflicts This is a job for an experienced programmer Neither C Craft nor The Software Toolworks can provide advice or assistance beyond the information in this chapter The routines are grouped onto manual pages For each routine above the name of its manual page
80. ve any dots in it If a pathname with slashes is given then only the last directory in the path is created All of the others must already exist The rmdir command removes one or more sub directories The directories must already be empty see rm cmnd If a pathname with slashes is given then only the last directory in the path is removed Sub directories are represented by a file in the parent directory with the name Of the sub directory and the extension sd where is a character in the range 1 to5 or a to z The files of the sub directory are stored under a CP M user number determined by this last character 1 to 5 are user l to 5 a is user 6 b is user 7 etc up to 3l NOTES A single mkdir command cannot create both a directory and a sub directory within it For example this will NOT work mkdir sources sources pascal Won t work This on the other hand WILL work mkdir sources mkdir sources pascal Will work This is because the shell translates all pathnames to simple filenames before a command is executed In the first case the sources directory does not yet exist so that sources pascal cannot be translated to J pascal for example The second case works because the former mkdir finishes before the shell attempts to translate sources pascal A maximum of 31 sub directories may be created on a single disk If any CP M user numbers fram 1 to 3l are already in use on the disk they can not be used as direct
81. y is set the file is also accessible to be opened by any running program This allows library files for example to be stored in the top directory for access from any directory The requirement of the SYS flag being set can be eliminated by patching cnixhigh sys see patches info SEE ALSO p cmnd ls cmnd pathname cmd LIMITATIONS Clearing the writeable flag on a directory file should perhaps prevent adding or removing components from the directory 99 cp cmnd Copy a File or Files cp cmnd NAME cp Copy a File or Files SYNOPSIS c y q filefrom fileto f q filel file2 file3 dir D The cp command copies one file to a new one or copies a set of files to another directory Cp will ask for confirmation if a file already exists with the new name flag forces copy without asking for confirmation regardless of whether the target file exists The rm command may be used to remove existing files before copying to them The first form of cp takes two filenames it copies the first to the second This is equivalent to a simple use of the PIP command The second form of cp takes one or more filenames and a directory name All the files are copied onto files with the corresponding names in the specified directory The filenames may contain wildcards in which case all matching files will be copied into the specified directory The directory must exist but if it contains any files w
Download Pdf Manuals
Related Search
Related Contents
聖闘士聖衣皇級 海皇ポセイドン 取扱説明書 1.7 MB Bedienungsanleitung - SICOM - Prozeß 取扱説明書 - KAWAJUN Media Converter User Manual SRT−G060 取扱説明書 - 株式会社 旭エンジニアリング Hemostatix Thermal Scalpel Handle Bedienungsanleitung LCD-Fernseher Samsung GE 102Y-S User Manual SERVICE MANUAL - BigWarehouse Spares Parts Copyright © All rights reserved.
Failed to retrieve file