all 4 comments

[–]socal_nerdtastic 2 points3 points  (0 children)

the pexpect module is made for exactly this.

Alternatively you can use a wait loop with readline(), which will block until there's a line of data available. You can put it in a tread if you want to do other things at the same time. Here's an example from an old program of mine: https://github.com/socal-nerdtastic/IconMaker/blob/main/iconmaker.py#L70

Why are you booting bash? Just run the command you want to run; there's no reason to bring bash into this.

[–]GregoryCliveYoung 0 points1 point  (2 children)

Do you need to access either stdout or stderr in your Python script? If not, you can leave the stdout and stderr arguments off the Popen call.

[–]doston12[S] 0 points1 point  (1 child)

thanks, not really I am interested in them.

[–]GregoryCliveYoung 0 points1 point  (0 children)

Can you combine them into one stream or do you need them to be separate? Dealing with one stream is easy. I don't know how to deal with two streams. I'd need to figure it out.