#Tailing a file using subprocess.Popen and using stdout

1 messages · Page 1 of 1 (latest)

acoustic badger
#

I am attempting to use tail to read until the end of a text file but eventually need to be able to use a library along with the tailing.

Currently, I have

f = subprocess.Popen('tail -c+1 -f %s' % file_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
        while True:
            print(f.stdout)

but it just prints "<_io.BufferedReader name=3>"

I am on Windows.
Any and all advice is welcome.

midnight ibex
#

I am not sure if this works, but you can try asbytes = f.stdout.read(); asstring = asbytes.decode('utf-8')