Skip to content

Instantly share code, notes, and snippets.

@corpix
Last active August 29, 2015 14:23
Show Gist options
  • Save corpix/1166fb5612217d428083 to your computer and use it in GitHub Desktop.
Save corpix/1166fb5612217d428083 to your computer and use it in GitHub Desktop.
Execute command for each line
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import subprocess
while True:
x = sys.stdin.readline().strip()
if x != "":
subprocess.check_call(sys.argv[1:] + [x], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment