繁体   English   中英

Javascript-如何找到找到匹配项的PID?

[英]Javascript - how to find the PID where match found?

我有以下字符串作为缓冲区(它们是具有随机列值的随机行)。

如何从找到的ROW中准确搜索可用ROW中的“警告”,如何过滤PID?

var exec = require('child_process').exec;
exec('TASKLIST /v /FI "IMAGENAME eq python*"', function(a,b,c) {
  console.log(b);
  // Which PID contain the word : "Warnning" ? can you list them chronologically?


});

输出:

Image Name                     PID Session Name        Session#    Mem Usage Status          User Name                                              CPU Time Window Title
========================= ======== ================ =========== ============ =============== ================================================== ============ =====================================================
python.exe                    9999 RDP-Tcp#10                 1     19?556 K Running         sun\tpt                                                 0:00:15 Warnning of windows
python.exe                    3861 RDP-Tcp#10                 1     19?556 K Running         sun\tpt                                                 0:00:15 Cancle this crap
python.exe                    8080 RDP-Tcp#10                 1     19?556 K Running         sun\tpt                                                 0:00:15 Warnning of windows

在exec过滤器中,提供必要的过滤器以代替Running。

exec('TASKLIST /v /fi "STATUS eq Running" /FI "IMAGENAME eq Shoretel*" /FO csv /NH', 
    function(a,b,c) {

      // function to get the pids
      function getPID(csv){
          var pids = [];
          var lines=csv.split("\n");
          for(var i=0;i<lines.length - 1;i++){
              var headers=lines[i].split('",');
              pids.push(headers[1].split('"')[1]);
          }
          return pids;
      }

      // to get the pids
      getPID(b);
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM