Debian Codegraph @

upstream/debian-unstable/man1/expect_unbuffer.1

raw
1 .TH UNBUFFER 1 "1 June 1994"
2 .SH NAME
3 unbuffer \- unbuffer output
4 .SH SYNOPSIS
5 .B unbuffer
6 .I program
7 [
8 .I args
9 ]
10 .SH INTRODUCTION
11 .B unbuffer
12 disables the output buffering that occurs when program output
13 is redirected from non-interactive programs.
14 For example, suppose you are watching the output from a fifo by running it
15 through od and then more.
16 .nf
17
18 od \-c /tmp/fifo | more
19
20 .fi
21 You will not see anything until a full page
22 of output has been produced.
23
24 You can disable this automatic buffering as follows:
25
26 .nf
27
28 unbuffer od \-c /tmp/fifo | more
29
30 .fi
31 Normally, unbuffer does not read from stdin. This simplifies use of unbuffer in some situations. To use unbuffer in a pipeline, use the \-p flag.
32 Example:
33 .nf
34
35 process1 | unbuffer \-p process2 | process3
36 .fi
37 .SH CAVEATS
38
39 unbuffer \-p may appear to work incorrectly if a process feeding input
40 to unbuffer exits. Consider:
41 .nf
42 process1 | unbuffer \-p process2 | process3
43
44 .fi
45 If process1 exits, process2 may not yet have finished. It is
46 impossible for unbuffer to know long to wait for process2 and process2
47 may not ever finish, for example, if it is a filter. For expediency,
48 unbuffer simply exits when it encounters an EOF from either its input
49 or process2.
50
51 In order to have a version of unbuffer that worked in all situations,
52 an oracle would be necessary. If you want an application-specific
53 solution, workarounds or hand-coded Expect may be more suitable. For
54 example, the following example shows how to allow grep to finish
55 processing when the cat before it finishes first. Using cat to feed
56 grep would never require unbuffer in real life. It is merely a
57 placeholder for some imaginary process that may or may not finish.
58 Similarly, the final cat at the end of the pipeline is also a
59 placeholder for another process.
60
61 .nf
62
63 $ cat /tmp/abcdef.log | grep abc | cat
64 abcdef
65 xxxabc defxxx
66 $ cat /tmp/abcdef.log | unbuffer grep abc | cat
67 $ (cat /tmp/abcdef.log ; sleep 1) | unbuffer grep abc | cat
68 abcdef
69 xxxabc defxxx
70 $
71 .fi
72 .SH BUGS
73
74 The man page is longer than the program.
75
76 .SH SEE ALSO
77 .I
78 "Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
79 \fRby Don Libes,
80 O'Reilly and Associates, January 1995.
81 .SH AUTHOR
82 Don Libes, National Institute of Standards and Technology