I have to run the UNIX specific command using python and capture only the line after "Test Failed: " line. The approach I used is:
import os
def system_check(command: str):
stream = os.popen(command)
output = stream.readlines()
for line in output:
if line.strip().startswith('Test Failed: '):
for line in output:
print(line)
This reads every line starting from the beginning, not only after "Test Failed". If I use file reading as in How to only read lines in a text file after a certain string? it works.