Skip to content

Instantly share code, notes, and snippets.

@vindir
Created October 2, 2014 20:30
Show Gist options
  • Select an option

  • Save vindir/17b8c2ed3ac59f4026f1 to your computer and use it in GitHub Desktop.

Select an option

Save vindir/17b8c2ed3ac59f4026f1 to your computer and use it in GitHub Desktop.
subprocess examples
# Simple process Popen object
proc = subprocess.Popen([echo, '-n', my_combo_breaker], stdout=subprocess.PIPE)
# Dumping standard out to a var
#proc = subprocess.Popen([echo, '-n', my_combo_breaker], stdout=subprocess.PIPE).stdout.read().strip()
# Piping output of echo to pbcopy
#echo_out = subprocess.Popen([echo, '-n', my_combo_breaker], stdout=subprocess.PIPE)
#subprocess.Popen(['pbcopy'], stdin=echo_out)
# Doing it sensibly and just pushing stdin (broken currently)
pbcopy = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
pbcopy.communicate(input=my_combo_breaker)
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment