Waits and reads data until pattern is found.
Data received while WaitFor was running.
WaitFor method will receive data from the server until specified Pattern is found, or timeout expires.
NOTE: this method works only when Blocking property is set to True.
Very common way for using WaitFor method is to read all data that servers sends us upon connection. Usually zou will know exactly what you need to receive, so you can use this command to help you, like this:
Ssh1.Hostname = "yourhost"; Ssh1.Login = "tester"; Ssh1.Password = "weonlydo"; Ssh1.Protocol = WeOnlyDo.Client.SSH.SupportedProtocols.SSHAuto; Ssh1.Blocking = true; Ssh1.Connect(); Console.Write(Ssh1.WaitFor("joe@yourhost"));This sample will block until 'joe@yourhost' is found within received text. If it's not found in reasonable time (until timeout expires), you will still be able to call Receive to obtain received data.
As mentioned above, you can provide regular expression to be set as expected
response. You should prepend Pattern argument with regex: text so
wodSSH.NET knows you are using regular expression. For example, you can use it
Console.Write (Ssh1.WaitFor("regex:[\\$%#>] $"));above regular expression will match when:
typically, our previous sample joe@somehost:~$<SPACE> does match above regex. But, hey, feel free to use something more complex such as:
or using extended PERL syntax
just don't forget to put 'regex:' text in front of regular expression, otherwise wodSSH.NET will search for exact match of specified pattern.