Pexpect没有输出log

今天在同事的服务器上执行一个python脚本,发现它在运行的时候始终没有打印命令的log。

因为pexpect的初始logfile是指向None,所以我修改了logfile,但是发现还是没有输出。

child = pexpect.spawn('some_command')
child.logfile = sys.stdout

于是我去查看了一下pexpect.py,发现在它的版本很低,,logfile是定义成log_file。所以只需修改一下变量名称就好了。

Pexpect is Open Source, Free, and all Good that stuff.
License: Python Software Foundation License
         http://www.opensource.org/licenses/PythonSoftFoundation.html

Noah Spurrier

$Revision: 1.84 $
$Date: 2003/09/17 17:26:12 $

        self.STDIN_FILENO = sys.stdin.fileno()
        self.STDOUT_FILENO = sys.stdout.fileno()
        self.STDERR_FILENO = sys.stderr.fileno()

        self.stdin = sys.stdin
        self.stdout = sys.stdout
        self.stderr = sys.stderr

        self.timeout = timeout
        self.child_fd = -1 # initially closed
        self.__child_fd_owner = None
        self.exitstatus = None
        self.pid = None
        self.log_file = None
        self.before = None
        self.after = None
        self.match = None
        self.softspace = 0 # File-like object.



你可能感兴趣的:(Pexpect没有输出log)