Posted By

brm on 06/21/15


Tagged

Shell sysadmin


Versions (?)

Shell spawing command


 / Published in: Python
 

Spawning shell / command prompt based environment

  1. #!/usr/bin/python
  2.  
  3. import os
  4.  
  5. args = ""
  6. walk = os.getcwd()
  7. while argss != "quit":
  8. args = raw_input(""+walk+"> ")
  9. if args.split(" ")[0] == "cd":
  10. try:
  11. os.chdir(args.split(" ")[1])
  12. walk = os.getcwd()
  13. except:
  14. print "no such command"
  15. else:
  16. args2 = os.popen(args)
  17. print args2.read()

Report this snippet  

You need to login to post a comment.