Diff
Not logged in

Differences From Artifact [976b86f6bb]:

To Artifact [b844a99705]:


1
2
3

4
5
6
7
8

9
10
11
12
13
14
15
1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
16



+




-
+







'\"
'\" Copyright (c) 1993 The Regents of the University of California.
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
'\" Copyright (c) 2006 Donal K. Fellows.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\" 
'\" RCS: @(#) $Id: exec.n,v 1.6.4.5 2004/12/09 23:00:28 dgp Exp $
'\" RCS: @(#) $Id: exec.n,v 1.6.4.6 2007/04/08 14:58:46 dgp Exp $
'\" 
.so man.macros
.TH exec n 8.5 Tcl "Tcl Built-In Commands"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
exec \- Invoke subprocesses
25
26
27
28
29
30
31






32
33
34
35
36
37
38
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45







+
+
+
+
+
+







where each \fIarg\fR becomes one word of a command, and
each distinct command becomes a subprocess.
.PP
If the initial arguments to \fBexec\fR start with \fB\-\fR then
they are treated as command-line switches and are not part
of the pipeline specification.  The following switches are
currently supported:
.TP 13
\fB\-ignorestderr\fR
.VS 8.5
Stops the \fBexec\fR command from treating the output of messages to the
pipeline's standard error channel as an error case.
.VE 8.5
.TP 13
\fB\-keepnewline\fR
Retains a trailing newline in the pipeline's output.
Normally a trailing newline will be deleted.
.TP 13
\fB\-\|\-\fR
Marks the end of switches.  The argument following this one will
133
134
135
136
137
138
139
140




141
142
143
144
145
146
147
140
141
142
143
144
145
146

147
148
149
150
151
152
153
154
155
156
157







-
+
+
+
+







If any of the commands in the pipeline exit abnormally or
are killed or suspended, then \fBexec\fR will return an error
and the error message will include the pipeline's output followed by
error messages describing the abnormal terminations; the
\fB-errorcode\fR return option will contain additional information
about the last abnormal termination encountered.
If any of the commands writes to its standard error file and that
standard error isn't redirected,
standard error isn't redirected
.VS 8.5
and \fB\-ignorestderr\fR is not specified,
.VE 8.5
then \fBexec\fR will return an error;  the error message
will include the pipeline's standard output, followed by messages
about abnormal terminations (if any), followed by the standard error
output.
.PP
If the last character of the result or error message
is a newline then that character is normally deleted
363
364
365
366
367
368
369
370

371
372
373
374
375
376
377
373
374
375
376
377
378
379

380
381
382
383
384
385
386
387







-
+







.CE
.PP
If you are converting invocations involving shell globbing, you should
remember that Tcl does not handle globbing or expand things into
multiple arguments by default.  Instead you should write things like
this:
.CS
\fBexec\fR ls -l {expand}[glob *.tcl]
\fBexec\fR ls -l {*}[glob *.tcl]
.CE
.PP
.SH "WINDOWS EXAMPLES"
Here are some examples of the use of the \fBexec\fR command on Windows.
.PP
To start an instance of \fInotepad\fR editing a file without waiting
for the user to finish editing the file:
403
404
405
406
407
408
409
410

411
412
413
414
415
416
417
413
414
415
416
417
418
419

420
421
422
423
424
425
426
427







-
+







.PP
When in doubt, use the command \fBauto_execok\fR: it will return the
complete path to the program as seen by the \fBexec\fR command.  This
applies especially when you want to run "internal" commands like
\fIdir\fR from a Tcl script (if you just want to list filenames, use
the \fBglob\fR command.)  To do that, use this:
.CS
\fBexec\fR {expand}[auto_execok dir] *.tcl
\fBexec\fR {*}[auto_execok dir] *.tcl
.CE

.SH "SEE ALSO"
error(n), open(n)

.SH KEYWORDS
execute, pipeline, redirection, subprocess