Spawn Shell
This is probably the most python way to write this code.
spawnshell.py (download)
#!/usr/bin/python
# -*- Coding: utf-8 -*-
import os
import sys
while True:
cmd = raw_input('$ ').strip()
if cmd == "exit": sys.exit(0)
if cmd == "": continue
args = cmd.split()
res = os.spawnvp(os.P_WAIT, args[0], args)
if res==127: print >>sys.stderr,\
"command not found: %s" % args[0]
spawn takes care of creating the child and everything. This is Python, lad!