Skip to content

Instantly share code, notes, and snippets.

@laixintao
Last active January 20, 2020 11:55
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 laixintao/21599449956d218482a6a3087164b516 to your computer and use it in GitHub Desktop.
Save laixintao/21599449956d218482a6a3087164b516 to your computer and use it in GitHub Desktop.
from subprocess import run
# not working, Bad file descriptor
run(
"head /dev/random -c 100",
stdout=open("/tmp/head.out", "wb", 0).fileno(),
shell=True,
)
from subprocess import run
out = open("/tmp/head.out", "wb", 0)
run(
"head /dev/random -c 100",
stdout=out.fileno(),
shell=True,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment