Menu

Macro - Won't receive last line (4.3.13b)

Help
Andi Arey
2015-05-16
2015-05-20
  • Andi Arey

    Andi Arey - 2015-05-16

    Help,

    Poderosa macro ReceiveLine(), never get last line. sample below:

    host# show date
    2015/05/16
    host#
    --> the ReceiveLine() method never get the 2nd "host#"

    host# ssh host2
    password:
    --> the ReceiveLine() method never reach the "password:"

    Thank you

     
  • Iwasa Kazmi

    Iwasa Kazmi - 2015-05-18

    You can use ReceiveData() for reading line which doesn't end with a new-line character.
    It just returns current content of the internal buffer.
    Small delay by System.Threading.Thread.Sleep() before ReceiveData() will help to buffer the line.

     
  • Andi Arey

    Andi Arey - 2015-05-19

    I use both ReceiveData() and ReceiveData(delay). if I force call ReceiveData(delay) 100 times, it doesn't read anything in lastline. I'll try the beta 14.

     
  • Andi Arey

    Andi Arey - 2015-05-20

    this problem still exist in beta 14

    this my code:

    conn.TransmitLn("ssh " + l[0] + "@" + host[0]);
    op = ReceivePrompt(sw);
    if(op.Contains('(yes/no)?'))
    {
    conn.TransmitLn("yes");
    op = ReceivePrompt(sw);
    }

    if(op.Contains("password:"))
    conn.TransmitLn(l[1]);


    function ReceivePrompt(sw)
    {
    var prompt = /\n[%$>#] $/;
    var op = conn.ReceiveLine();
    var ok = true;
    var failCount = 0;

    while(ok)
    {
        var op2 = conn.ReceiveLine(100);
        if(op2!=null)
        {
            op += "\n" + op2;
            if(sw!=null)
                sw.WriteLine(op2);
        }
        else
        {
            failCount++;
            if(failCount==20)
                ok = false;
        }
    }
    return op;
    

    }

     
    • Iwasa Kazmi

      Iwasa Kazmi - 2015-05-20

      var op2 = conn.ReceiveLine(100);

      conn.ReceiveData(100) would give the expected result here.

      ReceiveLine(t) waits for the end of line until the timeout.
      If a new-line code was not detected, ReceiveLine(t) returns null
      even if other data exist in the internal buffer.

      var op = conn.ReceiveLine();

      There is no need to change this first ReceiveLine().
      This line will read echo back of the text you sent.

      To check the value of the variable, trace window will help.

      var env = new Poderosa.Macro.Environment();
      env.Debug.ShowTraceWindow();
        :
      env.Debug.Trace('op = ' + op);
      
       

Log in to post a comment.