Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Popen subprocess.PIPE and its uses

I know that this question may have been asked a lot but I am still not really getting it. Reading from this related link, I can understand why there is a need to add stdout=subprocess.PIPE at the end of the sentence so that the output result can be used into the next Popen.

Tried looking online, but I garner little to no knowledge about it as the ones I found are in the form of a documentation.

But if I am not using the output, is it really necessary to put stdout=subprocess.PIPE at the end? I tried executing it with and without the use of it, and it is still giving me the expected results that I wanted.

Hence what are the big differences whether subprocess.PIPE is present or not?

process = subprocess.Popen(command, stdout=subprocess.PIPE)
process.communicate()
like image 806
yan Avatar asked Dec 25 '22 06:12

yan


1 Answers

Without subprocess.PIPE the output of command would be printed on STDOUT and process.communicate() should return None. Which python version are you using?

Can you paste the output?

like image 93
Supratim Avatar answered Dec 31 '22 14:12

Supratim