2 # -*- coding: utf-8 -*-
4 """line_exec.py - Send all lines from stdin to specified programs
6 Reads from stdin and sends every line to the program(s) specified on the
9 File ID: 0a869b50-f45a-11e2-bb76-a088b4ddef28
10 License: GNU General Public License version 2 or later.
18 def exec_line(line
, args
):
20 pipe
= subprocess
.Popen(
22 stdin
=subprocess
.PIPE
,
23 stdout
=subprocess
.PIPE
,
24 stderr
=subprocess
.PIPE
,
26 (stdout
, stderr
) = pipe
.communicate(line
)
27 sys
.stdout
.write(stdout
)
29 sys
.stderr
.write(stderr
)
34 from optparse
import OptionParser
36 parser
= OptionParser()
43 help="Text string to add after every line output",
52 help="Text string to add before every line output",
55 (opt
, args
) = parser
.parse_args()
60 sys
.stdout
.write(opt
.before
)
62 sys
.stdout
.write(opt
.after
)
66 if __name__
== "__main__":