0

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

Glowie
  • 2,271
  • 21
  • 60
  • 104
  • 1
    try 'print out' instead of 'print pst' – ρss May 15 '14 at 18:22
  • @pss -- this solved my problem. However, I have new question that I posted here, http://stackoverflow.com/questions/23686333/python-script-not-executing-sysinternals-command – Glowie May 15 '14 at 18:47

1 Answers1

2

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.

ρss
  • 5,115
  • 8
  • 43
  • 73