Last active
December 27, 2015 17:59
-
-
Save inaz2/7366430 to your computer and use it in GitHub Desktop.
子プロセスの標準入力に書き込む
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python write_stdin.py | |
6 | |
20 | |
13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from subprocess import Popen, PIPE | |
p = Popen(['perl', '-nle', 'print length'], stdin=PIPE) | |
p.stdin.write("output\n") | |
p.stdin.write("number of characters\n") | |
p.stdin.write("for each line\n") | |
p.stdin.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment