Script to match lines in screen

I'd like to ask people who knows bash scripting to write me a script which would open a specific screen and match lines.

Here is algorithm I'm thinking about.

  1. Find SCREENS named name1, name2.... and nameX.
  2. Open them one by one and type 'STATS'
  3. Match last lines of the screen before command type and after.
  4. If lines don't match - move on to the next screen, if they do close current screen and run gaming server start line (I'll write this myself).

Note: Lines matching should be performed few times with few mins delays.

So the context of my problem is that I have few Counter-Strike gaming servers. Sometimes they crash and I have manually restart them. I'd like this to change.

I'm using Debian 6.0 32bit.

I'm not sure by what you mean for 'open the screens'. Is this firing up an application or something?

Finding the files should be easy with the find command, but pushing in the word STATS may defen on what you are actually doing to how you push it in.

Can you show us the content of these files and the code you are running to 'open' them?

Please wrap code and data input/output in CODE tags, like this:-

to produce the following (fixed character width, space respected):-

This is my code

Not only does it make posts far easier to read, but CODE and ICODE sections respect multiple space and have fixed width characters, which is important for easily seeing input/output requirements.

Regards,
Robin

When I type

screen -r

I get list of screens

In each of them I run my gaming server. So screen works like a console. When I open some screen

screen -r pb

I see the following

http://i.imgur.com/0esTOBm.png

If I type "STATS" when server is online last line always changes.

If server would be offline last line would remain the same before and after typing "STATS".

Each screen I create with similar line

screen -A -m -d -S pb linux32 ./hlds_run -game cstrike +map de_dust2_2x2 +maxplayers 21 +port 27017 +ip 77.241.192.156

So, this is screen as in vt100 sessions using a GUI or the like then I think.

I regret that I do not have that software installed and have never explored it. perhaps another can offer you some assistance.

Sorry about that, :o
Robin