Achim Domma (Procoders) wrote: > I'm writing a simple shell using cmd.Cmd. It would be very usefull if I > could read the commands as batchjob from a file. I've tried the following:
[...] Your original approach should work too if you clear the use_rawinput flag and provide a do_EOF() method that handles the file end: import cmd class Cmd(cmd.Cmd): def do_this(self, arg): print "this>", arg def do_that(self, arg): print " <that", arg def do_quit(self, arg): print "That's all, folks" return True do_EOF = do_quit if __name__ == "__main__": import sys filename = sys.argv[1] c = Cmd(stdin=file(filename)) c.use_rawinput = False c = c.cmdloop() Peter -- http://mail.python.org/mailman/listinfo/python-list