simple configurable shell, but it somehow doesn't always use the stream i give it...
the commands and the 'default' function somehow use the stream i give them as stdout, but the stdin and stdout of cmd_loop is allways on sys.stdin/sys.stdout
import cmd
class Interpreter(cmd.Cmd):
intro = None
prompt = '# > ' # from config
commands = [('command', 'response')]
def do_command(self, args):
self.stdout.write('response\n')
def emptyline(self):
self.stdout.write('nothing\n')
channelfile = channel.makefile('rw')
interpreter = Interpreter('tab', channelfile, channelfile)
interpreter.cmdloop()
can someone help me?
ok, never mind... forgot to set use_rawinput = False
Обсуждают сегодня