-1

I am writing to file as below

subprocess.Popen(['adb', 'logcat', '>', 'log.txt'])

But rather than writing to file it writes to console. I guess it is reading first 2 commands only?

user2661518
  • 2,677
  • 9
  • 42
  • 79

1 Answers1

1

I don't believe that redirection with '>' works with subprocess. However, you can define where output goes by specifying it in 'stderr' like so:

f = open('log.txt', 'w')
p = subprocess.Popen(['abd', 'logcat'], stdout=f)

Hope this helps.

ham_string
  • 139
  • 5