This project is read-only.

Expect - Howto read 2 lines

Aug 26, 2013 at 2:07 AM
Edited Aug 26, 2013 at 2:08 AM

hope you read this ...
I wanted to use your Library to control 3 of our game servers. I just want to use simple commands so I decided to use your 'Expect' function. I just have a problem with expecting 2 lines which the server answers to my command.
I know my english is not very good, I'll just try to eyplain my problem:

For example, I send the command
shutdown 30 shutdownmessage
The server now answers with these two lines:
The server will be shut down in 30 seconds
From now on I don't really know how to 'Expect' the message "The server will be shutdown in 30 seconds".

Also it seems like 'Expect' always start reading on other parts of the server answer.
Sometimes it reads "rver will me shut down in 30 seconds \r\n13;1Husername[at]server:~$"
and sometimes it contains the whole command i sended before.

I hope you understand my problem and you can help me.

Here my code i just added to a WindowsForms Button, just for testing
            TcpClient tc = new TcpClient(hostname, port2);
            TelnetStream ts = new TelnetStream(tc.GetStream());
            ts.SetRemoteMode(TelnetOption.Echo, true);
            Expector ex = new Expector(ts);
            ex.ExpectTimeout = new TimeSpan(0, 0, 5);
            ex.Expect(username + "@zulu193:~$");
            ex.SendLine("shutdown " + nud_private_shutdown_delay.Value + " " + tb_private_shutdown_message.Text);
            ex.Expect(username + "@zulu193:~$");
            toolstrip_lb_status.Text = "Shutdown Befehl an Server \"Regular\" gesendet!";