printing stdout in realtime from subprocess

后端 未结 2 321
一整个雨季
一整个雨季 2021-01-22 07:48

I want to print rather than catch the output from a bash command (more closer to real-time than this post). For instance, I have a script like this:

from subproc         


        
2条回答
  •  旧巷少年郎
    2021-01-22 08:43

    import subprocess
    cmd = 'rsync --rsh=ssh -rv thisdir/ servername:folder/'
    subprocess.call(cmd, shell=True)
    

    (The shell=True paramater interprets the string by passing it to sh, allowing sh to split the string into tokens.)

提交回复
热议问题