I am running a python on Linux terminal and it requires some bash commands to run while the test is running. So, I am using the subprocess module and running my test commands (bash script). These so-called bash commands might print something on the CLI which I need to know if it does while I am running my python code in parallel.
for Ex :
# running my python TCP server
subprocess.call(['.\run_some_shell_commands.sh'],shell=True)
while True:
# I am doing some other python stuff
if (CLI_HAS_SOME_OUTPUT_DETECTED):
#record the output to some variable
# doing some more python stuff
If I know for sure that run_some_shell_commands.sh returns some output for sure, I could simply use A = subprocess.checkoutput(['.\run_some_shell_commands.sh'],shell=True) which would save its output in variable A ..
Is there any way to grab the last n lines of the terminal ?? so that I can check if that event has occurred and I can assign that to CLI_HAS_SOME_OUTPUT_DETECTED
Any suggestions are highly appreciated.
Saira