Skip to content Skip to sidebar Skip to footer

Binding / Piping Output Of Run() On/into Function In Python3 (lynux)

I am trying to use output of external program run using the run function. this program regularly throws a row of data which i need to use in mine script I have found a subprocess l

Solution 1:

SO, I have solved it. First step was to start the external script: proc=Popen('./cisla.sh', stdout=PIPE, bufsize=1)

Next I have started a function that would read it and passed it a pipe

deffoo(proc, **args):
       for i in proc.stdout:
         '''Do all I want to do with each'''

foo(proc).start()`

Limitations are: If your wish t catch scripts error you would have to pipe it in. second is that it leaves a zombie if you kill parrent SO dont forget to kill child in signal-handling

Post a Comment for "Binding / Piping Output Of Run() On/into Function In Python3 (lynux)"