Skip to content

Instantly share code, notes, and snippets.

@icatalina
Last active November 13, 2017 11:49
Show Gist options
  • Save icatalina/3708c320aa0260a9fa7532a5b6bc5d96 to your computer and use it in GitHub Desktop.
Save icatalina/3708c320aa0260a9fa7532a5b6bc5d96 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
"""
Processes an stdin and prompts for confirmation
"""
import sys
def process():
"""
Processes an stdin and prompts for confirmation
"""
input_value = sys.stdin.read()
sys.stdin = open('/dev/tty')
old_stdout = sys.stdout
try:
sys.stdout = sys.stderr
print input_value.strip()
selected_option = raw_input('Continue (y/N)? ')
finally:
sys.stdout = old_stdout
if selected_option == 'y':
print input_value
else:
sys.exit(1)
process()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment