Created
April 24, 2019 05:00
-
-
Save weaming/80d0be5e5e2db5790a6d7fe31a930bf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# coding: utf-8 | |
""" | |
Author : weaming | |
Created Time : 2019-04-24 12:41:48 | |
""" | |
import subprocess | |
import sys | |
import os | |
def run_shell(command): | |
return subprocess.run([os.getenv("SHELL") or "bash", "-c", command]).returncode | |
def read_lines(): | |
rv = [] | |
for x in sys.stdin: | |
x = x.rstrip("\n") | |
x = x.lstrip("$ ") | |
if x == "DONE": | |
break | |
rv.append(x) | |
return rv | |
commands = "; ".join(read_lines()) | |
sys.eixt(run_shell(commands)) |
Author
weaming
commented
Apr 24, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment