Skip to content

Instantly share code, notes, and snippets.

@inaz2
Last active December 27, 2015 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inaz2/7366430 to your computer and use it in GitHub Desktop.
Save inaz2/7366430 to your computer and use it in GitHub Desktop.
子プロセスの標準入力に書き込む
$ python write_stdin.py
6
20
13
#!/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