Skip to content

Instantly share code, notes, and snippets.

@OsandaMalith
Created October 3, 2019 10:15
Show Gist options
  • Save OsandaMalith/5ab6f77b85d3db680a3c67d8a81348cb to your computer and use it in GitHub Desktop.
Save OsandaMalith/5ab6f77b85d3db680a3c67d8a81348cb to your computer and use it in GitHub Desktop.
A simple python shell
import subprocess
import os
import sys
'''
A simple python shell
Author: @OsandaMalith
'''
while True:
try:
Input = raw_input("Osanda> ")
cmd = Input.split()
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
o, e = proc.communicate()
print (o.decode('ascii'))
print(e.decode('ascii'))
except Exception, e:
continue
except KeyboardInterrupt:
sys.exit("\nClosing shell...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment