⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exec.n

📁 linux系统下的音频通信
💻 N
字号:
'\"'\" Copyright (c) 1993 The Regents of the University of California.'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" SCCS: @(#) exec.n 1.17 96/09/18 15:21:17'\" .so man.macros.TH exec n 7.6 Tcl "Tcl Built-In Commands".BS'\" Note:  do not modify the .SH NAME line immediately below!.SH NAMEexec \- Invoke subprocess(es).SH SYNOPSIS\fBexec \fR?\fIswitches\fR? \fIarg \fR?\fIarg ...\fR?.BE.SH DESCRIPTION.PPThis command treats its arguments as the specificationof one or more subprocesses to execute.The arguments take the form of a standard shell pipelinewhere each \fIarg\fR becomes one word of a command, andeach distinct command becomes a subprocess..PPIf the initial arguments to \fBexec\fR start with \fB\-\fR thenthey are treated as command-line switches and are not partof the pipeline specification.  The following switches arecurrently supported:.TP 13\fB\-keepnewline\fRRetains a trailing newline in the pipeline's output.Normally a trailing newline will be deleted..TP 13\fB\-\|\-\fRMarks the end of switches.  The argument following this one willbe treated as the first \fIarg\fR even if it starts with a \fB\-\fR..PPIf an \fIarg\fR (or pair of \fIarg\fR's) has one of the formsdescribed below then it is used by \fBexec\fR to control theflow of input and output among the subprocess(es).Such arguments will not be passed to the subprocess(es).  In formssuch as ``< \fIfileName\fR'' \fIfileName\fR may either be in aseparate argument from ``<'' or in the same argument with nointervening space (i.e. ``<\fIfileName\fR'')..TP 15|Separates distinct commands in the pipeline.  The standard outputof the preceding command will be piped into the standard inputof the next command..TP 15|&Separates distinct commands in the pipeline.  Both standard outputand standard error of the preceding command will be piped intothe standard input of the next command.This form of redirection overrides forms such as 2> and >&..TP 15<\0\fIfileName\fRThe file named by \fIfileName\fR is opened and used as the standardinput for the first command in the pipeline..TP 15<@\0\fIfileId\fR\fIFileId\fR must be the identifier for an open file, such as the returnvalue from a previous call to \fBopen\fR.It is used as the standard input for the first command in the pipeline.\fIFileId\fR must have been opened for reading..TP 15<<\0\fIvalue\fR\fIValue\fR is passed to the first command as its standard input..TP 15>\0\fIfileName\fRStandard output from the last command is redirected to the file named\fIfileName\fR, overwriting its previous contents..TP 152>\0\fIfileName\fRStandard error from all commands in the pipeline is redirected to thefile named \fIfileName\fR, overwriting its previous contents..TP 15>&\0\fIfileName\fRBoth standard output from the last command and standard error from allcommands are redirected to the file named \fIfileName\fR, overwritingits previous contents..TP 15>>\0\fIfileName\fRStandard output from the last command isredirected to the file named \fIfileName\fR, appending to it ratherthan overwriting it..TP 152>>\0\fIfileName\fRStandard error from all commands in the pipeline isredirected to the file named \fIfileName\fR, appending to it ratherthan overwriting it..TP 15>>&\0\fIfileName\fRBoth standard output from the last command and standard error fromall commands are redirected to the file named \fIfileName\fR,appending to it rather than overwriting it..TP 15>@\0\fIfileId\fR\fIFileId\fR must be the identifier for an open file, such as the returnvalue from a previous call to \fBopen\fR.Standard output from the last command is redirected to \fIfileId\fR'sfile, which must have been opened for writing..TP 152>@\0\fIfileId\fR\fIFileId\fR must be the identifier for an open file, such as the returnvalue from a previous call to \fBopen\fR.Standard error from all commands in the pipeline isredirected to \fIfileId\fR's file.The file must have been opened for writing..TP 15>&@\0\fIfileId\fR\fIFileId\fR must be the identifier for an open file, such as the returnvalue from a previous call to \fBopen\fR.Both standard output from the last command and standard error fromall commands are redirected to \fIfileId\fR's file.The file must have been opened for writing..PPIf standard output has not been redirected then the \fBexec\fRcommand returns the standard output from the last commandin the pipeline.If any of the commands in the pipeline exit abnormally orare killed or suspended, then \fBexec\fR will return an errorand the error message will include the pipeline's output followed byerror messages describing the abnormal terminations; the\fBerrorCode\fR variable will contain additional informationabout the last abnormal termination encountered.If any of the commands writes to its standard error file and thatstandard error isn't redirected,then \fBexec\fR will return an error;  the error messagewill include the pipeline's standard output, followed by messagesabout abnormal terminations (if any), followed by the standard erroroutput..PPIf the last character of the result or error messageis a newline then that character is normally deletedfrom the result or error message.This is consistent with other Tcl return values, which don'tnormally end with newlines.However, if \fB\-keepnewline\fR is specified then the trailingnewline is retained..PPIf standard input isn't redirected with ``<'' or ``<<''or ``<@'' then the standard input for the first command in thepipeline is taken from the application's current standard input..PPIf the last \fIarg\fR is ``&'' then the pipeline will beexecuted in background.In this case the \fBexec\fR command will return a list whoseelements are the process identifiers for all of the subprocessesin the pipeline.The standard output from the last command in the pipeline willgo to the application's standard output if it hasn't beenredirected, and error output from all ofthe commands in the pipeline will go to the application'sstandard error file unless redirected..PPThe first word in each command is taken as the command name;tilde-substitution is performed on it, and if the result containsno slashes then the directoriesin the PATH environment variable are searched foran executable by the given name.If the name contains a slash then it must refer to an executablereachable from the current directory.No ``glob'' expansion or other shell-like substitutionsare performed on the arguments to commands..VS.SH "PORTABILITY ISSUES".TP\fBWindows\fR (all versions).Reading from or writing to a socket, using the ``\fB@\0\fIfileId\fR''notation, does not work.  When reading from a socket, a 16-bit DOSapplication will hang and a 32-bit application will return immediately withend-of-file.  When either type of application writes to a socket, theinformation is instead sent to the console, if one is present, or isdiscarded..spThe Tk console text widget does not provide real standard IO capabilities.Under Tk, when redirecting from standard input, all applications will see animmediate end-of-file; information redirected to standard output or standarderror will be discarded.  .spEither forward or backward slashes are accepted as path separators forarguments to Tcl commands.  When executing an application, the path namespecified for the application may also contain forward or backward slashesas path separators.  Bear in mind, however, that most Windows applicationsaccept arguments with forward slashes only as option delimiters andbackslashes only in paths.  Any arguments to an application that specify apath name with forward slashes will not automatically be converted to usethe backslash character.  If an argument contains forward slashes as thepath separator, it may or may not be recognized as a path name, depending onthe program.  .spAdditionally, when calling a 16-bit DOS or Windows 3.X application, all pathnames must use the short, cryptic, path format (e.g., using ``applba~1.def''instead of ``applbakery.default'')..spTwo or more forward or backward slashes in a row in a path refer to anetwork path.  For example, a simple concatenation of the root directory\fBc:/\fR with a subdirectory \fB/windows/system\fR will yield\fBc://windows/system\fR (two slashes together), which refers to thedirectory \fB/system\fR on the machine \fBwindows\fR (and the \fBc:/\fR isignored), and is not equivalent to \fBc:/windows/system\fR, which describesa directory on the current computer..TP\fBWindows NT\fR.When attempting to execute an application, \fBexec\fR first searches for thename as it was specified.  Then, in order, \fB.com\fR, \fB.exe\fR, and \fB.bat\fR are appended to the end of the specified name and it searches forthe longer name.  If a directory name was not specified as part of theapplication name, the following directories are automatically searched inorder when attempting to locate the application:.sp.RS.RSThe directory from which the Tcl executable was loaded..brThe current directory..brThe Windows NT 32-bit system directory..brThe Windows NT 16-bit system directory..brThe Windows NT home directory..brThe directories listed in the path..RE.spIn order to execute the shell builtin commands like \fBdir\fR and \fBcopy\fR,the caller must prepend ``\fBcmd.exe /c\0\fR'' to the desired command.  .sp.RE.TP\fBWindows 95\fR.When attempting to execute an application, \fBexec\fR first searches for thename as it was specified.  Then, in order, \fB.com\fR, \fB.exe\fR, and \fB.bat\fRare appended to the end of the specified name and it searches forthe longer name.  If a directory name was not specified as part of theapplication name, the following directories are automatically searched inorder when attempting to locate the application:.sp.RS.RSThe directory from which the Tcl executable was loaded..brThe current directory..brThe Windows 95 system directory..brThe Windows 95 home directory..brThe directories listed in the path..RE.spIn order to execute the shell builtin commands like \fBdir\fR and \fBcopy\fR,the caller must prepend ``\fBcommand.com /c\0\fR'' to the desired command..spOnce a 16-bit DOS application has read standard input from a console and then quit, all subsequently run 16-bit DOS applications will see the standard input as already closed.  32-bit applications do not have thisproblem and will run correctly even after a 16-bit DOS application thinks that standard input is closed.  There is no known workaround for this bugat this time..spRedirection between the \fBNUL:\fR device and a 16-bit application does notalways work.  When redirecting from \fBNUL:\fR, some applications may hang,others will get an infinite stream of ``0x01'' bytes, and some will actuallycorrectly get an immediate end-of-file; the behavior seems to depend upon something compiled into the application itself.  When redirecting greater than4K or so to \fBNUL:\fR, some applications will hang.  The above problems do nothappen with 32-bit applications.  .spAll DOS 16-bit applications are run synchronously.  All standard input froma pipe to a 16-bit DOS application is collected into a temporary file; theother end of the pipe must be closed before the 16-bit DOS applicationbegins executing.  All standard output or error from a 16-bit DOSapplication to a pipe is collected into temporary files; the applicationmust terminate before the temporary files are redirected to the next stageof the pipeline.  This is due to a workaround for a Windows 95 bug in the implementation of pipes, and is how the Windows 95 command line interpreterhandles pipes itself..spCertain applications, such as \fBcommand.com\fR, should not be executedinteractively.  Applications which directly access the console window,rather than reading from their standard input and writing to their standardoutput may fail, hang Tcl, or even hang the system if their own privateconsole window is not available to them..RE.TP\fBWindows 3.X\fR.When attempting to execute an application, \fBexec\fR first searches for thename as it was specified.  Then, in order, \fB.com\fR, \fB.exe\fR, and \fB.bat\fRare appended to the end of the specified name and it searches forthe longer name.  If a directory name was not specified as part of theapplication name, the following directories are automatically searched inorder when attempting to locate the application:.sp.RS.RSThe directory from which the Tcl executable was loaded..brThe current directory..brThe Windows 3.X system directory..brThe Windows 3.X home directory..brThe directories listed in the path..RE.spIn order to execute the shell builtin commands like \fBdir\fR and \fBcopy\fR,the caller must prepend ``\fBcommand.com /c\0\fR'' to the desired command..sp16-bit and 32-bit DOS and Windows applications may be executed.  However,redirection and piping of standard IO only works with 16-bit DOSapplications.  32-bit applications always see standard input as alreadyclosed, and any standard output or error is discarded, no matter where in thepipeline the application occurs or what redirection symbols are used by thecaller.  Additionally, for 16-bit applications, standard error is alwayssent to the same place as standard output; it cannot be redirected to aseparate location.  In order to achieve pseudo-redirection for 32-bitapplications, the 32-bit application must instead be written to take commandline arguments that specify the files that it should read from and write toand open those files itself.  .spAll applications, both 16-bit and 32-bit, run synchronously; each applicationruns to completion before the next one in the pipeline starts.  Temporary filesare used to simulate piping between applications.  The \fBexec\fRcommand cannot be used to start an application in the background..spWhen standard input is redirected from an open file using the``\fB@\0\fIfileId\fR'' notation, the open file is completely read up to itsend.  This is slightly different than under Windows 95 or NT, where the childapplication consumes from the open file only as much as it wants.Redirecting to an open file is supported as normal..RE.TP\fBMacintosh\fRThe \fBexec\fR command is not implemented and does not exist under Macintosh..TP\fBUnix\fR\0\0\0\0\0\0\0The \fBexec\fR command is fully functional and works as described..SH "SEE ALSO"open(n).VE.SH KEYWORDSexecute, pipeline, redirection, subprocess

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -