OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / man / mann / exec.n
1 '\"
2 '\" Copyright (c) 1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\" Copyright (c) 2006 Donal K. Fellows.
5 '\"
6 '\" See the file "license.terms" for information on usage and redistribution
7 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8 '\" 
9 .TH exec n 8.5 Tcl "Tcl Built-In Commands"
10 .\" The -*- nroff -*- definitions below are for supplemental macros used
11 .\" in Tcl/Tk manual entries.
12 .\"
13 .\" .AP type name in/out ?indent?
14 .\"     Start paragraph describing an argument to a library procedure.
15 .\"     type is type of argument (int, etc.), in/out is either "in", "out",
16 .\"     or "in/out" to describe whether procedure reads or modifies arg,
17 .\"     and indent is equivalent to second arg of .IP (shouldn't ever be
18 .\"     needed;  use .AS below instead)
19 .\"
20 .\" .AS ?type? ?name?
21 .\"     Give maximum sizes of arguments for setting tab stops.  Type and
22 .\"     name are examples of largest possible arguments that will be passed
23 .\"     to .AP later.  If args are omitted, default tab stops are used.
24 .\"
25 .\" .BS
26 .\"     Start box enclosure.  From here until next .BE, everything will be
27 .\"     enclosed in one large box.
28 .\"
29 .\" .BE
30 .\"     End of box enclosure.
31 .\"
32 .\" .CS
33 .\"     Begin code excerpt.
34 .\"
35 .\" .CE
36 .\"     End code excerpt.
37 .\"
38 .\" .VS ?version? ?br?
39 .\"     Begin vertical sidebar, for use in marking newly-changed parts
40 .\"     of man pages.  The first argument is ignored and used for recording
41 .\"     the version when the .VS was added, so that the sidebars can be
42 .\"     found and removed when they reach a certain age.  If another argument
43 .\"     is present, then a line break is forced before starting the sidebar.
44 .\"
45 .\" .VE
46 .\"     End of vertical sidebar.
47 .\"
48 .\" .DS
49 .\"     Begin an indented unfilled display.
50 .\"
51 .\" .DE
52 .\"     End of indented unfilled display.
53 .\"
54 .\" .SO ?manpage?
55 .\"     Start of list of standard options for a Tk widget. The manpage
56 .\"     argument defines where to look up the standard options; if
57 .\"     omitted, defaults to "options". The options follow on successive
58 .\"     lines, in three columns separated by tabs.
59 .\"
60 .\" .SE
61 .\"     End of list of standard options for a Tk widget.
62 .\"
63 .\" .OP cmdName dbName dbClass
64 .\"     Start of description of a specific option.  cmdName gives the
65 .\"     option's name as specified in the class command, dbName gives
66 .\"     the option's name in the option database, and dbClass gives
67 .\"     the option's class in the option database.
68 .\"
69 .\" .UL arg1 arg2
70 .\"     Print arg1 underlined, then print arg2 normally.
71 .\"
72 .\" .QW arg1 ?arg2?
73 .\"     Print arg1 in quotes, then arg2 normally (for trailing punctuation).
74 .\"
75 .\" .PQ arg1 ?arg2?
76 .\"     Print an open parenthesis, arg1 in quotes, then arg2 normally
77 .\"     (for trailing punctuation) and then a closing parenthesis.
78 .\"
79 .\"     # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
80 .if t .wh -1.3i ^B
81 .nr ^l \n(.l
82 .ad b
83 .\"     # Start an argument description
84 .de AP
85 .ie !"\\$4"" .TP \\$4
86 .el \{\
87 .   ie !"\\$2"" .TP \\n()Cu
88 .   el          .TP 15
89 .\}
90 .ta \\n()Au \\n()Bu
91 .ie !"\\$3"" \{\
92 \&\\$1 \\fI\\$2\\fP (\\$3)
93 .\".b
94 .\}
95 .el \{\
96 .br
97 .ie !"\\$2"" \{\
98 \&\\$1  \\fI\\$2\\fP
99 .\}
100 .el \{\
101 \&\\fI\\$1\\fP
102 .\}
103 .\}
104 ..
105 .\"     # define tabbing values for .AP
106 .de AS
107 .nr )A 10n
108 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
109 .nr )B \\n()Au+15n
110 .\"
111 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
112 .nr )C \\n()Bu+\\w'(in/out)'u+2n
113 ..
114 .AS Tcl_Interp Tcl_CreateInterp in/out
115 .\"     # BS - start boxed text
116 .\"     # ^y = starting y location
117 .\"     # ^b = 1
118 .de BS
119 .br
120 .mk ^y
121 .nr ^b 1u
122 .if n .nf
123 .if n .ti 0
124 .if n \l'\\n(.lu\(ul'
125 .if n .fi
126 ..
127 .\"     # BE - end boxed text (draw box now)
128 .de BE
129 .nf
130 .ti 0
131 .mk ^t
132 .ie n \l'\\n(^lu\(ul'
133 .el \{\
134 .\"     Draw four-sided box normally, but don't draw top of
135 .\"     box if the box started on an earlier page.
136 .ie !\\n(^b-1 \{\
137 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
138 .\}
139 .el \}\
140 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
141 .\}
142 .\}
143 .fi
144 .br
145 .nr ^b 0
146 ..
147 .\"     # VS - start vertical sidebar
148 .\"     # ^Y = starting y location
149 .\"     # ^v = 1 (for troff;  for nroff this doesn't matter)
150 .de VS
151 .if !"\\$2"" .br
152 .mk ^Y
153 .ie n 'mc \s12\(br\s0
154 .el .nr ^v 1u
155 ..
156 .\"     # VE - end of vertical sidebar
157 .de VE
158 .ie n 'mc
159 .el \{\
160 .ev 2
161 .nf
162 .ti 0
163 .mk ^t
164 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
165 .sp -1
166 .fi
167 .ev
168 .\}
169 .nr ^v 0
170 ..
171 .\"     # Special macro to handle page bottom:  finish off current
172 .\"     # box/sidebar if in box/sidebar mode, then invoked standard
173 .\"     # page bottom macro.
174 .de ^B
175 .ev 2
176 'ti 0
177 'nf
178 .mk ^t
179 .if \\n(^b \{\
180 .\"     Draw three-sided box if this is the box's first page,
181 .\"     draw two sides but no top otherwise.
182 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
183 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
184 .\}
185 .if \\n(^v \{\
186 .nr ^x \\n(^tu+1v-\\n(^Yu
187 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
188 .\}
189 .bp
190 'fi
191 .ev
192 .if \\n(^b \{\
193 .mk ^y
194 .nr ^b 2
195 .\}
196 .if \\n(^v \{\
197 .mk ^Y
198 .\}
199 ..
200 .\"     # DS - begin display
201 .de DS
202 .RS
203 .nf
204 .sp
205 ..
206 .\"     # DE - end display
207 .de DE
208 .fi
209 .RE
210 .sp
211 ..
212 .\"     # SO - start of list of standard options
213 .de SO
214 'ie '\\$1'' .ds So \\fBoptions\\fR
215 'el .ds So \\fB\\$1\\fR
216 .SH "STANDARD OPTIONS"
217 .LP
218 .nf
219 .ta 5.5c 11c
220 .ft B
221 ..
222 .\"     # SE - end of list of standard options
223 .de SE
224 .fi
225 .ft R
226 .LP
227 See the \\*(So manual entry for details on the standard options.
228 ..
229 .\"     # OP - start of full description for a single option
230 .de OP
231 .LP
232 .nf
233 .ta 4c
234 Command-Line Name:      \\fB\\$1\\fR
235 Database Name:  \\fB\\$2\\fR
236 Database Class: \\fB\\$3\\fR
237 .fi
238 .IP
239 ..
240 .\"     # CS - begin code excerpt
241 .de CS
242 .RS
243 .nf
244 .ta .25i .5i .75i 1i
245 ..
246 .\"     # CE - end code excerpt
247 .de CE
248 .fi
249 .RE
250 ..
251 .\"     # UL - underline word
252 .de UL
253 \\$1\l'|0\(ul'\\$2
254 ..
255 .\"     # QW - apply quotation marks to word
256 .de QW
257 .ie '\\*(lq'"' ``\\$1''\\$2
258 .\"" fix emacs highlighting
259 .el \\*(lq\\$1\\*(rq\\$2
260 ..
261 .\"     # PQ - apply parens and quotation marks to word
262 .de PQ
263 .ie '\\*(lq'"' (``\\$1''\\$2)\\$3
264 .\"" fix emacs highlighting
265 .el (\\*(lq\\$1\\*(rq\\$2)\\$3
266 ..
267 .\"     # QR - quoted range
268 .de QR
269 .ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3
270 .\"" fix emacs highlighting
271 .el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3
272 ..
273 .\"     # MT - "empty" string
274 .de MT
275 .QW ""
276 ..
277 .BS
278 '\" Note:  do not modify the .SH NAME line immediately below!
279 .SH NAME
280 exec \- Invoke subprocesses
281 .SH SYNOPSIS
282 \fBexec \fR?\fIswitches\fR? \fIarg \fR?\fIarg ...\fR? ?\fB&\fR?
283 .BE
284 .SH DESCRIPTION
285 .PP
286 This command treats its arguments as the specification
287 of one or more subprocesses to execute.
288 The arguments take the form of a standard shell pipeline
289 where each \fIarg\fR becomes one word of a command, and
290 each distinct command becomes a subprocess.
291 .PP
292 If the initial arguments to \fBexec\fR start with \fB\-\fR then
293 they are treated as command-line switches and are not part
294 of the pipeline specification.  The following switches are
295 currently supported:
296 .TP 13
297 \fB\-ignorestderr\fR
298 .
299 Stops the \fBexec\fR command from treating the output of messages to the
300 pipeline's standard error channel as an error case.
301 .TP 13
302 \fB\-keepnewline\fR
303 .
304 Retains a trailing newline in the pipeline's output.
305 Normally a trailing newline will be deleted.
306 .TP 13
307 \fB\-\|\-\fR
308 .
309 Marks the end of switches.  The argument following this one will
310 be treated as the first \fIarg\fR even if it starts with a \fB\-\fR.
311 .PP
312 If an \fIarg\fR (or pair of \fIarg\fRs) has one of the forms
313 described below then it is used by \fBexec\fR to control the
314 flow of input and output among the subprocess(es).
315 Such arguments will not be passed to the subprocess(es).  In forms
316 such as
317 .QW "\fB<\fR \fIfileName\fR" ,
318 \fIfileName\fR may either be in a separate argument from
319 .QW \fB<\fR
320 or in the same argument with no intervening space (i.e.
321 .QW \fB<\fIfileName\fR ).
322 .TP 15
323 \fB|\fR
324 .
325 Separates distinct commands in the pipeline.  The standard output
326 of the preceding command will be piped into the standard input
327 of the next command.
328 .TP 15
329 \fB|&\fR
330 .
331 Separates distinct commands in the pipeline.  Both standard output
332 and standard error of the preceding command will be piped into
333 the standard input of the next command.
334 This form of redirection overrides forms such as 2> and >&.
335 .TP 15
336 \fB<\0\fIfileName\fR
337 .
338 The file named by \fIfileName\fR is opened and used as the standard
339 input for the first command in the pipeline.
340 .TP 15
341 \fB<@\0\fIfileId\fR
342 .
343 \fIFileId\fR must be the identifier for an open file, such as the return
344 value from a previous call to \fBopen\fR.
345 It is used as the standard input for the first command in the pipeline.
346 \fIFileId\fR must have been opened for reading.
347 .TP 15
348 \fB<<\0\fIvalue\fR
349 .
350 \fIValue\fR is passed to the first command as its standard input.
351 .TP 15
352 \fB>\0\fIfileName\fR
353 .
354 Standard output from the last command is redirected to the file named
355 \fIfileName\fR, overwriting its previous contents.
356 .TP 15
357 \fB2>\0\fIfileName\fR
358 .
359 Standard error from all commands in the pipeline is redirected to the
360 file named \fIfileName\fR, overwriting its previous contents.
361 .TP 15
362 \fB>&\0\fIfileName\fR
363 .
364 Both standard output from the last command and standard error from all
365 commands are redirected to the file named \fIfileName\fR, overwriting
366 its previous contents.
367 .TP 15
368 \fB>>\0\fIfileName\fR
369 .
370 Standard output from the last command is
371 redirected to the file named \fIfileName\fR, appending to it rather
372 than overwriting it.
373 .TP 15
374 \fB2>>\0\fIfileName\fR
375 .
376 Standard error from all commands in the pipeline is
377 redirected to the file named \fIfileName\fR, appending to it rather
378 than overwriting it.
379 .TP 15
380 \fB>>&\0\fIfileName\fR
381 .
382 Both standard output from the last command and standard error from
383 all commands are redirected to the file named \fIfileName\fR,
384 appending to it rather than overwriting it.
385 .TP 15
386 \fB>@\0\fIfileId\fR
387 .
388 \fIFileId\fR must be the identifier for an open file, such as the return
389 value from a previous call to \fBopen\fR.
390 Standard output from the last command is redirected to \fIfileId\fR's
391 file, which must have been opened for writing.
392 .TP 15
393 \fB2>@\0\fIfileId\fR
394 .
395 \fIFileId\fR must be the identifier for an open file, such as the return
396 value from a previous call to \fBopen\fR.
397 Standard error from all commands in the pipeline is
398 redirected to \fIfileId\fR's file.
399 The file must have been opened for writing.
400 .TP 15
401 \fB2>@1\0\fR
402 .
403 Standard error from all commands in the pipeline is redirected to the
404 command result.  This operator is only valid at the end of the command
405 pipeline.
406 .TP 15
407 \fB>&@\0\fIfileId\fR
408 .
409 \fIFileId\fR must be the identifier for an open file, such as the return
410 value from a previous call to \fBopen\fR.
411 Both standard output from the last command and standard error from
412 all commands are redirected to \fIfileId\fR's file.
413 The file must have been opened for writing.
414 .PP
415 If standard output has not been redirected then the \fBexec\fR
416 command returns the standard output from the last command
417 in the pipeline, unless
418 .QW 2>@1
419 was specified, in which case standard error is included as well.
420 If any of the commands in the pipeline exit abnormally or
421 are killed or suspended, then \fBexec\fR will return an error
422 and the error message will include the pipeline's output followed by
423 error messages describing the abnormal terminations; the
424 \fB\-errorcode\fR return option will contain additional information
425 about the last abnormal termination encountered.
426 If any of the commands writes to its standard error file and that
427 standard error is not redirected
428 and \fB\-ignorestderr\fR is not specified,
429 then \fBexec\fR will return an error;  the error message
430 will include the pipeline's standard output, followed by messages
431 about abnormal terminations (if any), followed by the standard error
432 output.
433 .PP
434 If the last character of the result or error message
435 is a newline then that character is normally deleted
436 from the result or error message.
437 This is consistent with other Tcl return values, which do not
438 normally end with newlines.
439 However, if \fB\-keepnewline\fR is specified then the trailing
440 newline is retained.
441 .PP
442 If standard input is not redirected with
443 .QW < ,
444 .QW <<
445 or
446 .QW <@
447 then the standard input for the first command in the
448 pipeline is taken from the application's current standard input.
449 .PP
450 If the last \fIarg\fR is
451 .QW &
452 then the pipeline will be executed in background.
453 In this case the \fBexec\fR command will return a list whose
454 elements are the process identifiers for all of the subprocesses
455 in the pipeline.
456 The standard output from the last command in the pipeline will
457 go to the application's standard output if it has not been
458 redirected, and error output from all of
459 the commands in the pipeline will go to the application's
460 standard error file unless redirected.
461 .PP
462 The first word in each command is taken as the command name;
463 tilde-substitution is performed on it, and if the result contains
464 no slashes then the directories
465 in the PATH environment variable are searched for
466 an executable by the given name.
467 If the name contains a slash then it must refer to an executable
468 reachable from the current directory.
469 No
470 .QW glob
471 expansion or other shell-like substitutions
472 are performed on the arguments to commands.
473 .SH "PORTABILITY ISSUES"
474 .TP
475 \fBWindows\fR (all versions)
476 .
477 Reading from or writing to a socket, using the
478 .QW \fB@\0\fIfileId\fR
479 notation, does not work.  When reading from a socket, a 16-bit DOS
480 application will hang and a 32-bit application will return immediately with
481 end-of-file.  When either type of application writes to a socket, the
482 information is instead sent to the console, if one is present, or is
483 discarded.
484 .RS
485 .PP
486 The Tk console text widget does not provide real standard IO capabilities.
487 Under Tk, when redirecting from standard input, all applications will see an
488 immediate end-of-file; information redirected to standard output or standard
489 error will be discarded.  
490 .PP
491 Either forward or backward slashes are accepted as path separators for
492 arguments to Tcl commands.  When executing an application, the path name
493 specified for the application may also contain forward or backward slashes
494 as path separators.  Bear in mind, however, that most Windows applications
495 accept arguments with forward slashes only as option delimiters and
496 backslashes only in paths.  Any arguments to an application that specify a
497 path name with forward slashes will not automatically be converted to use
498 the backslash character.  If an argument contains forward slashes as the
499 path separator, it may or may not be recognized as a path name, depending on
500 the program.  
501 .PP
502 Additionally, when calling a 16-bit DOS or Windows 3.X application, all path
503 names must use the short, cryptic, path format (e.g., using
504 .QW applba~1.def
505 instead of
506 .QW applbakery.default ),
507 which can be obtained with the
508 .QW "\fBfile attributes\fI fileName \fB\-shortname\fR"
509 command.
510 .PP
511 Two or more forward or backward slashes in a row in a path refer to a
512 network path.  For example, a simple concatenation of the root directory
513 \fBc:/\fR with a subdirectory \fB/windows/system\fR will yield
514 \fBc://windows/system\fR (two slashes together), which refers to the mount
515 point called \fBsystem\fR on the machine called \fBwindows\fR (and the
516 \fBc:/\fR is ignored), and is not equivalent to \fBc:/windows/system\fR,
517 which describes a directory on the current computer.  The \fBfile join\fR
518 command should be used to concatenate path components.
519 .PP
520 Note that there are two general types of Win32 console applications:
521 .RS
522 .IP [1]
523 CLI \(em CommandLine Interface, simple stdio exchange. \fBnetstat.exe\fR for
524 example.
525 .IP [2]
526 TUI \(em Textmode User Interface, any application that accesses the console
527 API for doing such things as cursor movement, setting text color, detecting
528 key presses and mouse movement, etc.  An example would be \fBtelnet.exe\fR
529 from Windows 2000.  These types of applications are not common in a windows
530 environment, but do exist.
531 .RE
532 .PP
533 \fBexec\fR will not work well with TUI applications when a console is not
534 present, as is done when launching applications under wish.  It is desirable
535 to have console applications hidden and detached.  This is a designed-in
536 limitation as \fBexec\fR wants to communicate over pipes.  The Expect
537 extension addresses this issue when communicating with a TUI application.
538 .PP
539 When attempting to execute an application, \fBexec\fR first searches for
540 the name as it was specified.  Then, in order, \fB.com\fR, \fB.exe\fR, and
541 \fB.bat\fR are appended to the end of the specified name and it searches
542 for the longer name.  If a directory name was not specified as part of the
543 application name, the following directories are automatically searched in
544 order when attempting to locate the application:
545 .IP \(bu 3
546 The directory from which the Tcl executable was loaded.
547 .IP \(bu 3
548 The current directory.
549 .IP \(bu 3
550 The Windows NT 32-bit system directory.
551 .IP \(bu 3
552 The Windows NT 16-bit system directory.
553 .IP \(bu 3
554 The Windows NT home directory.
555 .IP \(bu 3
556 The directories listed in the path.
557 .PP
558 In order to execute shell built-in commands like \fBdir\fR and \fBcopy\fR,
559 the caller must prepend the desired command with
560 .QW "\fBcmd.exe /c\0\fR"
561 because built-in commands are not implemented using executables.
562 .RE
563 .TP
564 \fBUnix\fR (including Mac OS X)
565 .
566 The \fBexec\fR command is fully functional and works as described.
567 .SH "UNIX EXAMPLES"
568 .PP
569 Here are some examples of the use of the \fBexec\fR command on Unix.
570 To execute a simple program and get its result:
571 .PP
572 .CS
573 \fBexec\fR uname -a
574 .CE
575 .SS "WORKING WITH NON-ZERO RESULTS"
576 .PP
577 To execute a program that can return a non-zero result, you should
578 wrap the call to \fBexec\fR in \fBcatch\fR and check the contents
579 of the \fB\-errorcode\fR return option if you have an error:
580 .PP
581 .CS
582 set status 0
583 if {[catch {\fBexec\fR grep foo bar.txt} results options]} {
584     set details [dict get $options -errorcode]
585     if {[lindex $details 0] eq "CHILDSTATUS"} {
586         set status [lindex $details 2]
587     } else {
588         # Some other error; regenerate it to let caller handle
589         return -options $options -level 0 $results
590     }
591 }
592 .CE
593 .VS 8.6
594 .PP
595 This is more easily written using the \fBtry\fR command, as that makes
596 it simpler to trap specific types of errors. This is
597 done using code like this:
598 .PP
599 .CS
600 try {
601     set results [\fBexec\fR grep foo bar.txt]
602     set status 0
603 } trap CHILDSTATUS {results options} {
604     set status [lindex [dict get $options -errorcode] 2]
605 }
606 .CE
607 .VE 8.6
608 .SS "WORKING WITH QUOTED ARGUMENTS"
609 .PP
610 When translating a command from a Unix shell invocation, care should
611 be taken over the fact that single quote characters have no special
612 significance to Tcl.  Thus:
613 .PP
614 .CS
615 awk '{sum += $1} END {print sum}' numbers.list
616 .CE
617 .PP
618 would be translated into something like:
619 .PP
620 .CS
621 \fBexec\fR awk {{sum += $1} END {print sum}} numbers.list
622 .CE
623 .SS "WORKING WITH GLOBBING"
624 .PP
625 If you are converting invocations involving shell globbing, you should
626 remember that Tcl does not handle globbing or expand things into
627 multiple arguments by default.  Instead you should write things like
628 this:
629 .PP
630 .CS
631 \fBexec\fR ls -l {*}[glob *.tcl]
632 .CE
633 .SS "WORKING WITH USER-SUPPLIED SHELL SCRIPT FRAGMENTS"
634 .PP
635 One useful technique can be to expose to users of a script the ability
636 to specify a fragment of shell script to execute that will have some
637 data passed in on standard input that was produced by the Tcl program.
638 This is a common technique for using the \fIlpr\fR program for
639 printing. By far the simplest way of doing this is to pass the user's
640 script to the user's shell for processing, as this avoids a lot of
641 complexity with parsing other languages.
642 .PP
643 .CS
644 set lprScript [\fIget from user...\fR]
645 set postscriptData [\fIgenerate somehow...\fR]
646
647 \fBexec\fR $env(SHELL) -c $lprScript << $postscriptData
648 .CE
649 .SH "WINDOWS EXAMPLES"
650 .PP
651 Here are some examples of the use of the \fBexec\fR command on Windows.
652 To start an instance of \fInotepad\fR editing a file without waiting
653 for the user to finish editing the file:
654 .PP
655 .CS
656 \fBexec\fR notepad myfile.txt &
657 .CE
658 .PP
659 To print a text file using \fInotepad\fR:
660 .PP
661 .CS
662 \fBexec\fR notepad /p myfile.txt
663 .CE
664 .SS "WORKING WITH CONSOLE PROGRAMS"
665 .PP
666 If a program calls other programs, such as is common with compilers,
667 then you may need to resort to batch files to hide the console windows
668 that sometimes pop up:
669 .PP
670 .CS
671 \fBexec\fR cmp.bat somefile.c -o somefile
672 .CE
673 .PP
674 With the file \fIcmp.bat\fR looking something like:
675 .PP
676 .CS
677 @gcc %1 %2 %3 %4 %5 %6 %7 %8 %9
678 .CE
679 .SS "WORKING WITH COMMAND BUILT-INS"
680 .PP
681 Sometimes you need to be careful, as different programs may have the
682 same name and be in the path. It can then happen that typing a command
683 at the DOS prompt finds \fIa different program\fR than the same
684 command run via \fBexec\fR. This is because of the (documented)
685 differences in behaviour between \fBexec\fR and DOS batch files.
686 .PP
687 When in doubt, use the command \fBauto_execok\fR: it will return the
688 complete path to the program as seen by the \fBexec\fR command.  This
689 applies especially when you want to run
690 .QW internal
691 commands like
692 \fIdir\fR from a Tcl script (if you just want to list filenames, use
693 the \fBglob\fR command.)  To do that, use this:
694 .PP
695 .CS
696 \fBexec\fR {*}[auto_execok dir] *.tcl
697 .CE
698 .SS "WORKING WITH NATIVE FILENAMES"
699 .PP
700 Many programs on Windows require filename arguments to be passed in with
701 backslashes as pathname separators. This is done with the help of the
702 \fBfile nativename\fR command. For example, to make a directory (on NTFS)
703 encrypted so that only the current user can access it requires use of
704 the \fICIPHER\fR command, like this:
705 .PP
706 .CS
707 set secureDir "~/Desktop/Secure Directory"
708 file mkdir $secureDir
709 \fBexec\fR CIPHER /e /s:[file nativename $secureDir]
710 .CE
711 .SH "SEE ALSO"
712 error(n), file(n), open(n)
713 .SH KEYWORDS
714 execute, pipeline, redirection, subprocess
715 '\" Local Variables:
716 '\" mode: nroff
717 '\" End: