Hi
I wonder if you can help me. I am using pexpect with python to access remote machines and run commands on them. I pass commands into code like so:

def cmd(self, cmd):
        pp=[ "|", "]", "[", "(", ")", "$", "?", "*", ".", ":"]
        expcmd=cmd
        for element in pp:
            expcmd=expcmd.replace(element, "\\%s" % element)
        self.spawn.setecho(False)
        self.spawn.sendline(cmd)
        self.spawn.expect (expcmd)
        self.spawn.expect(self.prompt)
        return self.spawn.before

The above code is supposed to match the command, then match the prompt and then return what is in between. Since pexpect uses regular expressions to match what it sees
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to