Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the path of the running process #83

Open
ganeshkbhat opened this issue Mar 27, 2022 · 0 comments
Open

Get the path of the running process #83

ganeshkbhat opened this issue Mar 27, 2022 · 0 comments

Comments

@ganeshkbhat
Copy link

ganeshkbhat commented Mar 27, 2022

I have two nginx executables running.

  1. C:/nginx/nginx.exe (or say usr/bin)
  2. C:/second/nginx/nginx.exe (or say $home/local/nginx)

I wish to get the executable's path of the running nginx file whether it is the first or second. I am aware of this command wmic process where "ExecutablePath like 'c:\\nginx\\nginx%'" get ProcessID in windows. Is there a way I can do it using ps-node so it applies to both linux and win?

var ps = require('ps-node');
ps.lookup({
    command: 'nginx',
    psargs: 'ux'
    }, function(err, resultList ) {
    if (err) {
        throw new Error( err );
    }
    resultList.forEach(function( process ){
        if( process ){
            console.log(process.pid, process.command, **process.ExecutablePath**, process.arguments );
            // **process.ExecutablePath** => c:/nginx or usr/bin
        }
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant