Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • JScript: Verify if the given text is present in the Putty Console window

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 374
    Comment on it

    Hi All,
    Below you can find the code to verify if the given text is present in the Putty Console window. Function require three parameters i.e. Object of putty, the text to verify on console and the position to search for the text( Here the allowed values are Start, End, Anywhere(default value)).

    function searchTextInPuttyConsole(PuttyObject, TextToVerify, VerifyPosition)
    {
      if(VerifyPosition === undefined || VerifyPosition == null || aqString.Trim(VerifyPosition) == "")
      {
        VerifyPosition = "anywhere";
      }
    
      //Set the position to its lower case letters
      VerifyPosition = aqString.Trim(aqString.ToLower(VarToStr(VerifyPosition)));
    
      //gets the console text
      var consoleText =GetPuttyConsoleText(PuttyObject);
    
      var consoleHasString = false;
    
      switch(VerifyPosition)
      {
        case "start": 
          if(aqString.Find(consoleText, TextToVerify) == 0)
          {
            consoleHasString = true;
          }
          break;
        case "anywhere":
          if(aqString.Find(consoleText, TextToVerify) >= 0)
          {
            consoleHasString = true;
          }
          break;
        case "end":
          if(aqString.Find(consoleText, TextToVerify, consoleText.length - TextToVerify.length) >= 0)
          {
            consoleHasString = true;
          }
          break;
      }
    
      if(consoleHasString)
      {
        Log.Message("The given putty console contains the text'");
      }
      else
      {
        Log.Error("The putty console does not contains text ");
      }
    }
    function GetPuttyConsoleText(PuttyObject)
    {
      //Click the PuttyObject's
      PuttyObject.Click(PuttyObject.Left + 15, PuttyObject.Top + 15);
      aqUtils.Delay(200);
      PuttyObject.SystemMenu.Click("Copy All to Clipboard");
      //reads entire clipboard text
      var consoleText = VarToStr(Sys.Clipboard);
      //trims the consoletext
      consoleText = aqString.Trim(consoleText);
      //replaces unwanted spaces in the text read
      consoleText = aqString.Replace(consoleText, "     ", " ");
      consoleText = aqString.Replace(consoleText, "    ", " ");
      consoleText = aqString.Replace(consoleText, "   ", " ");
      consoleText = aqString.Replace(consoleText, "  ", " ");
      consoleText = aqString.Replace(consoleText, "  ", " ");
      return consoleText;
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: