Skip to content

Instantly share code, notes, and snippets.

@OsandaMalith
Created October 3, 2019 10:15
Show Gist options
  • Select an option

  • Save OsandaMalith/5ab6f77b85d3db680a3c67d8a81348cb to your computer and use it in GitHub Desktop.

Select an option

Save OsandaMalith/5ab6f77b85d3db680a3c67d8a81348cb to your computer and use it in GitHub Desktop.

Revisions

  1. OsandaMalith created this gist Oct 3, 2019.
    23 changes: 23 additions & 0 deletions shell.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    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...")