home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcl2-73c.zip / tcl7.3 / doc / exec.n < prev    next >
Text File  |  1993-07-23  |  8KB  |  199 lines

  1. '\"
  2. '\" Copyright (c) 1993 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/tcl/man/RCS/exec.n,v 1.6 93/07/23 15:13:34 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .so man.macros
  24. .HS exec tcl 7.0
  25. .BS
  26. '\" Note:  do not modify the .SH NAME line immediately below!
  27. .SH NAME
  28. exec \- Invoke subprocess(es)
  29. .SH SYNOPSIS
  30. \fBexec \fR?\fIswitches\fR? \fIarg \fR?\fIarg ...\fR?
  31. .BE
  32.  
  33. .SH DESCRIPTION
  34. .PP
  35. This command treats its arguments as the specification
  36. of one or more subprocesses to execute.
  37. The arguments take the form of a standard shell pipeline
  38. where each \fIarg\fR becomes one word of a command, and
  39. each distinct command becomes a subprocess.
  40. .PP
  41. If the initial arguments to \fBexec\fR start with \fB\-\fR then
  42. .VS
  43. they are treated as command-line switches and are not part
  44. of the pipeline specification.  The following switches are
  45. currently supported:
  46. .TP 13
  47. \fB\-keepnewline
  48. Retains a trailing newline in the pipeline's output.
  49. Normally a trailing newline will be deleted.
  50. .TP 13
  51. \fB\-\|\-\fR
  52. Marks the end of switches.  The argument following this one will
  53. be treated as the first \fIarg\fR even if it starts with a \fB\-.
  54. .VE
  55. .PP
  56. If an \fIarg\fR (or pair of \fIarg\fR's) has one of the forms
  57. described below then it is used by \fBexec\fR to control the
  58. flow of input and output among the subprocess(es).
  59. Such arguments will not be passed to the subprocess(es).  In forms
  60. .VS
  61. such as ``< \fIfileName\fR'' \fIfileName\fR may either be in a
  62. separate argument from ``<'' or in the same argument with no
  63. intervening space (i.e. ``<\fIfileName\fR'').
  64. .VE
  65. .TP 15
  66. |\fR
  67. Separates distinct commands in the pipeline.  The standard output
  68. of the preceding command will be piped into the standard input
  69. of the next command.
  70. .TP 15
  71. |&\fR
  72. Separates distinct commands in the pipeline.  Both standard output
  73. and standard error of the preceding command will be piped into
  74. the standard input of the next command.
  75. This form of redirection overrides forms such as 2> and >&.
  76. .TP 15
  77. <\0\fIfileName\fR
  78. The file named by \fIfileName\fR is opened and used as the standard
  79. input for the first command in the pipeline.
  80. .TP 15
  81. <@\0\fIfileId\fR
  82. .VS
  83. \fIFileId\fR must be the identifier for an open file, such as the return
  84. value from a previous call to \fBopen\fR.
  85. It is used as the standard input for the first command in the pipeline.
  86. \fIFileId\fR must have been opened for reading.
  87. .VE
  88. .TP 15
  89. <<\0\fIvalue\fR
  90. \fIValue\fR is passed to the first command as its standard input.
  91. .TP 15
  92. >\0\fIfileName\fR
  93. Standard output from the last command is redirected to the file named
  94. \fIfileName\fR, overwriting its previous contents.
  95. .TP 15
  96. 2>\0\fIfileName\fR
  97. .VS
  98. Standard error from all commands in the pipeline is redirected to the
  99. file named \fIfileName\fR, overwriting its previous contents.
  100. .TP 15
  101. >&\0\fIfileName\fR
  102. Both standard output from the last command and standard error from all
  103. commands are redirected to the file named \fIfileName\fR, overwriting
  104. its previous contents.
  105. .VE
  106. .TP 15
  107. >>\0\fIfileName\fR
  108. Standard output from the last command is
  109. redirected to the file named \fIfileName\fR, appending to it rather
  110. than overwriting it.
  111. .TP 15
  112. 2>>\0\fIfileName\fR
  113. .VS
  114. Standard error from all commands in the pipeline is
  115. redirected to the file named \fIfileName\fR, appending to it rather
  116. than overwriting it.
  117. .TP 15
  118. >>&\0\fIfileName\fR
  119. Both standard output from the last command and standard error from
  120. all commands are redirected to the file named \fIfileName\fR,
  121. appending to it rather than overwriting it.
  122. .TP 15
  123. >@\0\fIfileId\fR
  124. \fIFileId\fR must be the identifier for an open file, such as the return
  125. value from a previous call to \fBopen\fR.
  126. Standard output from the last command is redirected to \fIfileId\fR's
  127. file, which must have been opened for writing.
  128. .TP 15
  129. 2>@\0\fIfileId\fR
  130. \fIFileId\fR must be the identifier for an open file, such as the return
  131. value from a previous call to \fBopen\fR.
  132. Standard error from all commands in the pipeline is
  133. redirected to \fIfileId\fR's file.
  134. The file must have been opened for writing.
  135. .TP 15
  136. >&@\0\fIfileId\fR
  137. \fIFileId\fR must be the identifier for an open file, such as the return
  138. value from a previous call to \fBopen\fR.
  139. Both standard output from the last command and standard error from
  140. all commands are redirected to \fIfileId\fR's file.
  141. The file must have been opened for writing.
  142. .VE
  143. .PP
  144. If standard output has not been redirected then the \fBexec\fR
  145. command returns the standard output from the last command
  146. in the pipeline.
  147. If any of the commands in the pipeline exit abnormally or
  148. are killed or suspended, then \fBexec\fR will return an error
  149. and the error message will include the pipeline's output followed by
  150. error messages describing the abnormal terminations; the
  151. \fBerrorCode\fR variable will contain additional information
  152. about the last abnormal termination encountered.
  153. If any of the commands writes to its standard error file and that
  154. standard error isn't redirected,
  155. then \fBexec\fR will return an error;  the error message
  156. will include the pipeline's standard output, followed by messages
  157. about abnormal terminations (if any), followed by the standard error
  158. output.
  159. .PP
  160. If the last character of the result or error message
  161. is a newline then that character is normally deleted
  162. from the result or error message.
  163. This is consistent with other Tcl return values, which don't
  164. normally end with newlines.
  165. .VS
  166. However, if \fB\-keepnewline\fR is specified then the trailing
  167. newline is retained.
  168. .VE
  169. .PP
  170. If standard input isn't redirected with ``<'' or ``<<''
  171. or ``<@'' then the standard input for the first command in the
  172. pipeline is taken from the application's current standard input.
  173. .PP
  174. If the last \fIarg\fR is ``&'' then the pipeline will be
  175. executed in background.
  176. .VS
  177. In this case the \fBexec\fR command will return a list whose
  178. elements are the process identifiers for all of the subprocesses
  179. in the pipeline.
  180. .VE
  181. The standard output from the last command in the pipeline will
  182. go to the application's standard output if it hasn't been
  183. redirected, and error output from all of
  184. the commands in the pipeline will go to the application's
  185. standard error file unless redirected.
  186. .PP
  187. The first word in each command is taken as the command name;
  188. tilde-substitution is performed on it, and if the result contains
  189. no slashes then the directories
  190. in the PATH environment variable are searched for
  191. an executable by the given name.
  192. If the name contains a slash then it must refer to an executable
  193. reachable from the current directory.
  194. No ``glob'' expansion or other shell-like substitutions
  195. are performed on the arguments to commands.
  196.  
  197. .SH KEYWORDS
  198. execute, pipeline, redirection, subprocess
  199.