* better
[mascara-docs.git] / lang / C / the.ansi.c.programming.language / notes.accompany.ansi.c / sx10k.html
blob445b0361787f47547aec989fca4b826f38d41cd0
1 <!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
2 <!-- This collection of hypertext pages is Copyright 1995, 1996 by Steve Summit. -->
3 <!-- This material may be freely redistributed and used -->
4 <!-- but may not be republished or sold without permission. -->
5 <html>
6 <head>
7 <link rev="owner" href="mailto:scs@eskimo.com">
8 <link rev="made" href="mailto:scs@eskimo.com">
9 <title>section 7.8.4: Command Execution</title>
10 <link href="sx10j.html" rev=precedes>
11 <link href="sx10l.html" rel=precedes>
12 <link href="sx10.html" rev=subdocument>
13 </head>
14 <body>
15 <H2>section 7.8.4: Command Execution</H2>
17 page 167
18 <p>The only thing to add to this brief description of
19 <TT>system</TT> concerns the disposition of the executed
20 command's output.
21 (Similar arguments apply to its input.)
22 The output generally goes wherever the calling program's output goes,
23 though if the calling program has done anything with <TT>stdout</TT>
24 (such as closing it, or redirecting it within the program with
25 <TT>freopen</TT>),
26 those changes will probably <em>not</em> affect the output of
27 <TT>system</TT>.
28 One way to achieve redirection of the command executed by <TT>system</TT>,
29 if the operating system permits it, is to use redirection
30 notation <em>within</em> the command line passed to
31 <TT>system</TT>:
32 <pre> system("date &gt; outfile");
33 </pre>Note also that the exit status returned by the program
34 (and hence perhaps by <TT>system</TT>)
35 does not necessarily have anything to do
36 with anything printed by the program.
37 One way to capture the output printed by the program
38 is to use redirection, as above,
39 then open and read the output file.
40 </p><hr>
41 <p>
42 Read sequentially:
43 <a href="sx10j.html" rev=precedes>prev</a>
44 <a href="sx10l.html" rel=precedes>next</a>
45 <a href="sx10.html" rev=subdocument>up</a>
46 <a href="top.html">top</a>
47 </p>
48 <p>
49 This page by <a href="http://www.eskimo.com/~scs/">Steve Summit</a>
50 // <a href="copyright.html">Copyright</a> 1995, 1996
51 // <a href="mailto:scs@eskimo.com">mail feedback</a>
52 </p>
53 </body>
54 </html>