0

I want to execute a command and parse the output from the shell. I am using JScript inside TestComplete. I already found out that I can run commands using WScript.shell. But I do not know how to parse the output in my JScript. Any hints?

var shell = new ActiveXObject("WScript.shell");
if (shell)
{
  shell.run("myCommandIWantToParseOutputfrom.sh");
}

1 Answer 1

1

Take a look at the Exec method instead of Run.

var wsh = new ActiveXObject("WScript.Shell");
var cmd = wsh.Exec("cmd /c dir C:\ /on");

while (cmd.Status === 0) {
    WScript.Sleep(100);
}

var output = cmd.StdOut.ReadAll();
WScript.Echo(output);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.