【问题标题】:Parse script output from shell wanted in JScript解析 JScript 中需要的 shell 脚本输出
【发布时间】:2011-12-05 10:20:37
【问题描述】:

我想执行一个命令并解析 shell 的输出。我在 TestComplete 中使用 JScript。我已经发现我可以使用 WScript.shell 运行命令。但我不知道如何解析我的 JScript 中的输出。有什么提示吗?

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

【问题讨论】:

    标签: command-line activexobject jscript


    【解决方案1】:

    看看Exec 方法而不是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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多