1

I do the following and not able to read the file "word_file.txt" line by line..

 f = subprocess.Popen(["../../../script.sh", "cat", "word_file.txt"], stdout=subprocess.PIPE)
            out = f.stdout.readline()
            print "......."
            for i in f.stdout.readline():
                print "I>>>>>>>>>>>", i

the i that gets printed, prints every single character separately.

So, I tried doing..

for i in f.stdout.readline().split('\n'):
            print "I>>>>>>>>>>>", i

Read remote file using python subprocess and ssh? - addresses the same issue but their solution isnt working for me.

But that does not seem the right this to do. I get no output..

Community
  • 1
  • 1
user2921139
  • 1,669
  • 4
  • 17
  • 25

1 Answers1

0

use iter with readline to read each full line:

for i in iter(f.stdout.readline,"")
Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321