Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. if (process.pid) {
  2. console.log('This process is your pid ' + process.pid);
  3. }
  4.  
  5. console.log('This platform is ' + process.platform);
  6.  
  7. var exec = require('child_process').exec;
  8. var yourPID = '1444';
  9.  
  10. exec('tasklist', function(err, stdout, stderr) {
  11. var lines = stdout.toString().split('n');
  12. var results = new Array();
  13. lines.forEach(function(line) {
  14. var parts = line.split('=');
  15. parts.forEach(function(items){
  16. if(items.toString().indexOf(yourPID) > -1){
  17. console.log(items.toString().substring(0, items.toString().indexOf(yourPID)));
  18. }
  19. })
  20. });
  21. });
  22.  
  23. var spawn = require('child_process').spawn,
  24. cmdd = spawn('your_command'); //something like: 'man ps'
  25.  
  26. cmdd.stdout.on('data', function (data) {
  27. console.log('' + data);
  28. });
  29. cmdd.stderr.setEncoding('utf8');
  30. cmdd.stderr.on('data', function (data) {
  31. if (/^execvp()/.test(data)) {
  32. console.log('Failed to start child process.');
  33. }
  34. });
  35.  
  36. var process = require('process'); but it gave error.
  37.  
  38. console.log('This process is your pid ' + process.pid);
  39.  
  40. process.title = 'node-chat'
  41.  
  42. ps -aux | grep node-chat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement