Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (process.pid) {
- console.log('This process is your pid ' + process.pid);
- }
- console.log('This platform is ' + process.platform);
- var exec = require('child_process').exec;
- var yourPID = '1444';
- exec('tasklist', function(err, stdout, stderr) {
- var lines = stdout.toString().split('n');
- var results = new Array();
- lines.forEach(function(line) {
- var parts = line.split('=');
- parts.forEach(function(items){
- if(items.toString().indexOf(yourPID) > -1){
- console.log(items.toString().substring(0, items.toString().indexOf(yourPID)));
- }
- })
- });
- });
- var spawn = require('child_process').spawn,
- cmdd = spawn('your_command'); //something like: 'man ps'
- cmdd.stdout.on('data', function (data) {
- console.log('' + data);
- });
- cmdd.stderr.setEncoding('utf8');
- cmdd.stderr.on('data', function (data) {
- if (/^execvp()/.test(data)) {
- console.log('Failed to start child process.');
- }
- });
- var process = require('process'); but it gave error.
- console.log('This process is your pid ' + process.pid);
- process.title = 'node-chat'
- ps -aux | grep node-chat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement