|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T i ┃
Length: 7540 (0x1d74) Types: TextFile Names: »io«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen └─ ⟦this⟧ »cph85dist/stat/doc/cat/io«
IO(1) UNIX User's Manual IO(1) NAME io - control and monitor input/output (io) flow intelli- gently SYNOPSIS io [-mfa] [file ...] OPTIONS -m request monitoring of flow -f force overwrites of files without user interaction (useful in shell scripts) -a appends text the named file rather than overwriting it (only useful when output is being directed to a file) DESCRIPTION _▶08◀I_▶08◀o is a program that initiates, continues, and terminates input and output. It makes intelligent decisions about what it should do based on where it is called in a pipeline (beginning, middle, or end), whether it is given file argu- ments, and whether flow monitoring is requested. _▶08◀I_▶08◀o can replace shell file redirection used in shells (with <, > and >>), the simplest uses of _▶08◀c_▶08◀a_▶08◀t, the pipefitting pro- gram _▶08◀t_▶08◀e_▶08◀e, all with the ability to monitor the progress of the processes in a pipeline. EXAMPLES Some uses of _▶08◀i_▶08◀o are best shown by example: The following form simply prints the named files to the standard output: io file1 file2 file3 ... The following form redirects the output from the pipe to the named file. program1 | program2 | io file If the output file from _▶08◀i_▶08◀o exists, _▶08◀i_▶08◀o makes a temporary file before changing it to avoid the possibility of persons over-writing their input files. Thus, it is possible to sort a file onto itself with _▶08◀i_▶08◀o: sort foo | io foo is both legal and safe. _▶08◀I_▶08◀o will ask you if you want to safely overwrite any files that already exist, for which you should respond with a 'y' or a 'n'. To avoid having to interact with _▶08◀i_▶08◀o, see the -f flag which forces the safe overwrite. The following form simply continues the flow from standard input to standard output: program1 | io | program2 Printed 5/30/85 March 5, 1985 1 IO(1) UNIX User's Manual IO(1) When _▶08◀i_▶08◀o is used in the middle of a pipeline, it automati- cally monitors the flow of characters through it by printing a character about every 1000 bytes. This character changes from instance to instance of _▶08◀i_▶08◀o so that several flow meters can supply discriminable information. The character selec- tion is by process identification number, so that successive programs would have different flow characters. For example, the following shell command would set up three meters each with different flow characters: io foo | io | io | io -m bar The automatic monitoring of flow is not used if _▶08◀i_▶08◀o is used in the middle of a pipeline and is called with an argument file name. For example: program | io fubar | program In this case, the input to _▶08◀i_▶08◀o is copied into the file fubar, and another copy is continued along the pipeline. This is similar to the standard UNIX _▶08◀t_▶08◀e_▶08◀e program. The monitoring could be turned on if the -m flag were used: program | io -m fubar | program _▶08◀I_▶08◀o can replace the redirection symbols '<' (used to redirect the standard input), and '>' (used to redirect the standard output), used in the standard UNIX command shells, _▶08◀s_▶08◀h and _▶08◀c_▶08◀s_▶08◀h. io file | program has the same effect as: program < file but is a bit slower. And, program | io file is the same as program > file except that it is safer. _▶08◀I_▶08◀o can be used to append text to a file (emulating the shell >> redirection) by using the -a flag: program | io -a file is the exact same as program >> file If _▶08◀i_▶08◀o is called with the -m option, it will monitor the flow of bytes through it. For example, the following command sets up a bunch of flow meters. io -m file | io | io -m file When the flow meter is at the beginning of a pipeline, its meter prints the percent of its input so far read. Its speed depends on how fast programs down the pipeline are reading the output from whatever version of _▶08◀i_▶08◀o is used. Note that the -m flag is not needed in the middle of the pipeline as its only use in that context could be as a flow meter. Printed 5/30/85 March 5, 1985 2 IO(1) UNIX User's Manual IO(1) COMMENTS The conceptual model of UNIX for piping programs implies that we move data from some file, through several programs, and into another file, which -- conceptually at least, may be the same file as the data have come from. Thus, concep- tually, the flow through a pipe should look like this: file => program1 ==> program2 ==> ... ==> programN ==> file Within the existing UNIX shells, this pipe must be specified as program1 < file | program2 | ... | programN > temp mv temp file This specification of the pipe presents a system image of UNIX that conflicts with the underlying mental model of most users. First, the specification of "file" and "program1" are out of order; second, one must distinguish among "<" ">" and "|". The program _▶08◀i_▶08◀o is designed to allow a format more consistent with the underlying conceptualization. Along the way, it eliminates the need for distinguishing between <, >, and | and offers some new properties. Using _▶08◀i_▶08◀o, the example pipe can be written io file | program1 | program2 | ... | programN | io file DIAGNOSTICS The program has a lot of knowledge about how it is being used. It knows whether it is reading from piped input or from the terminal keyboard (tty). It also knows whether it is writing to a pipe or to the tty. It knows to check argu- ment files to see if ones to be read can be read, and if a file to be written exists, and if so, to make a temporary version of it before over-writing it. It also knows that depending on the combination of its information, that some combinations are not meaningful, and even dangerous. It will complain about all of these, and in most cases, break the pipeline it is in to the best of its ability. SEE ALSO sh(1), csh(1), cat(1), tee(1), more(1) AUTHORS Gary Perlman and Don Norman BUGS Hitting the BREAK or DEL keys while _▶08◀i_▶08◀o is overwriting a file can have bad effects. If you have several diversions to existing save files as in: pgm | io save.1 | pgm2 | io save.2 | pgm3 | io save.3 It will be confusing as all the different instances of _▶08◀i_▶08◀o ask you if you want to overwrite each. With several flow meters going at the same time, it is dif- ficult to figure what is going on. _▶08◀I_▶08◀o is better suited to a Printed 5/30/85 March 5, 1985 3 IO(1) UNIX User's Manual IO(1) system with better screen management. KEYWORDS input/output flow control/monitor Printed 5/30/85 March 5, 1985 4