Shell spawing command


/ Published in: Python
Save to your folder(s)

Spawning shell / command prompt based environment


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.