0

I have launched popen task ''' p = subprocess.Popen(['nmap', '-', '-oX', '192.168.19.159'], stdout=subprocess.PIPE) '''

In cmd tasklist command i can see pid of the laucnhed process (enter image description here)

Can i create new python script, from which i can connect to my launched process by pid and get stdout from launched process?

I tried libraries psutil,subprocess. But i did not find answer.

1 Answer 1

0

The documentation: https://docs.python.org/3/library/subprocess.html

It tells that the returned object of Popen provides stdout and stderr as fields for the captured output. You should be able to iterate over those lines.

Sign up to request clarification or add additional context in comments.

2 Comments

can i get the stdout variable in another py file?
It's not clear how you intend to use it. A python file that does create a process can capture its output as mentioned. What do you want to do with another python file?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.