ReadLine() public method

Reads the line from the shell. If line is not available it will block the execution and will wait for new line.
public ReadLine ( ) : string
return string
Exemplo n.º 1
0
 /// <summary>
 /// Read the output until we see a particular line.
 /// </summary>
 /// <param name="_stream"></param>
 /// <param name="p"></param>
 private void DumpTillFind(ShellStream stream, string matchText, Action<string> ongo = null)
 {
     while (true)
     {
         var l = stream.ReadLine();
         if (l == null)
         {
             Thread.Sleep(100);
         }
         else
         {
             if (l.Contains(matchText))
             {
                 return;
             }
             else
             {
                 if (ongo != null)
                 {
                     ongo(l);
                 }
             }
         }
     }
 }
Exemplo n.º 2
-1
        public SSHConnection(string host, string username)
        {
            this._host = host;
            this._username = username;

            _ssh = new SshClient(_host, _username, Passwords.FetchPassword(_host, _username));
            _ssh.Connect();
            _stream = _ssh.CreateShellStream("commands", 240, 200, 132, 80, 240 * 200);

            // Next job, wait until we get a command prompt

            _stream.WriteLine("# this is a test");
            DumpTillFind(_stream, "# this is a test");
            _prompt = _stream.ReadLine();
        }
Exemplo n.º 3
-1
        //terminalden gelen cevabi okumak icin tanimlamlanan cevapoku fonksiyonu..

       private void cevapoku(ShellStream stream)
         {
              try
              {
                  while (stream.DataAvailable)
                  {
                      okunan = stream.ReadLine();
                  }
                  okunan = Regex.Replace(okunan, @"\r", "");

                  int bas = okunan.IndexOf("<") + "<".Length;
                  int uzunluk = okunan.IndexOf(">") - bas;
                 
                  pinler = okunan.Substring(bas, uzunluk);
                  //pinoku = pinler.select(c => c.ToString()).ToArray();
              }
              catch
              {
                  tl.LogMessage("hata", "arduino okuma hatasi!!, kapat ac düzelir :) ");
              }
         }