#!/usr/bin/env python3 import fileinput import sys from subprocess import PIPE, Popen inp = fileinput.input() exe = next(inp).strip() args = "".join([line for line in inp]) try: proc = Popen( exe, stdin=PIPE, stdout=sys.stdout, stderr=sys.stderr, shell=True, encoding="utf-8", ) proc.communicate(input=args) except Exception: pass finally: exit(proc.returncode)