Hi,
An update on earlier with a bit more information about what I've been trying.
I need to monitor the output of a running process until the reported status is what I am expecting. This process watches a text file for an instruction to do something then reports to stdout what it is doing. I could see no easy way of doing this via existing keywords so have gone down a fairly convoluted route.
I start the process and pipe the stdout to a text file, and check the process is running:
Start Command Manager And Check Process Is Running
${prochandle} = Start Process ./my_process stdout=stdout.txt
Process Should be running ${prochandle}
Set Suite Variable ${prochandle}
I modify the text file that the process is watching for changes and uses as an input
Change Mode
${modestr} = set variable ModeChangeText
Create file /where/the/file/is/mode.txt ${modestr}
I wait for a few seconds to make sure the process has had time to begin populating the output file (I know sleep is unreliable but I'm open to suggestions here):
Wait For Mode Change
Sleep 5s
I then loop over the lines in the output file waiting for a keyword to match, but this is where I'm coming unstuck. The file is being continuously added to, so I need to re-initialise the ${lines} counter during each loop which just looks really unwieldy and probably wrong.
Loop Over Output File And Check For TextIWantToMatch
${filecontents} = Get File stdout.txt
@{lines} = Split to lines ${filecontents}
:FOR ${line} IN @{lines}
\ Wait Until Keyword Succeeds 0m 30s Strings Should Match ${line} TextIWantToMatch
\ ${filecontents} = Get File stdout.txt
\ @{lines} = Split to lines ${filecontents}
*** keyword ***
Strings Should Match
[arguments] ${stdoutstr} ${comparisonstr}
${status} = Should Be Equal ${stdoutstr} ${comparisonstr}
Is there an easier way to continuously 'watch' the content of a growing log file for a particular text string?
Many thanks in advance for any help with this one
Adam