Invoke pstools in Python script

被刻印的时光 ゝ 提交于 2020-01-17 01:21:14

问题


I am trying to invoke pstools (specifically, psloggedon.exe) in my Python script

import sys, subprocess, socket, string
import wmi, win32api, win32con

pst = subprocess.Popen(
        ["D:\pstools\psloggedon.exe", "-l", "-x", "\\10.10.10.10"],
        stdout = subprocess.PIPE,
        stderr = subprocess.PIPE
    )

out, error = pst.communicate()

print pst, "is output"

This is the output

<subprocess.Popen object at 0x0000000002B18D68> is output

I would like the output to be

DOMAIN\user

Thank You


回答1:


If you want to print the output then you have to use print out, "is output" instead of print pst, "is output" because out will contain the output.



来源:https://stackoverflow.com/questions/23685675/invoke-pstools-in-python-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!