SSH.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:Skynet2.0 作者: Skynet2-0 项目源码 文件源码
def run_as_stream(self, command, logpath):
        """
        runs a command over SSH on the client as a stream.
        i.e. for every line written by the client during running of command write this to logfile
        do not stop untill ssh has no more lines to write

        returns -- the output of the command as a string        
        """
        (ins, stdout, stderr) = self.client.exec_command(command)
        f = open(logpath, "a+")

        for line in stdout.readlines():
            print line
            f.write(line)
        for line in stderr.readlines():
            print line
            f.write(line)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号