var execFile = require('child_process').execFile;
execFile('lsof', ['-t', '-i:'+portnumber], function(err, stdout, stderr) {
   execFile('kill', [stdout], function(err, stdout, stderr) {
      // ...
   });
});

I'm skipping error checks for readability, but obviously they should be 
present in a real code.


On Thursday, June 13, 2013 1:02:32 PM UTC+4, Amit Kumar wrote:
>
> I need to to free a port by running a command kill `lsof -t -i:4723` from 
> a node.js file my code is
>
>      var sys = require('sys')
>     var exec = require('child_process').exec;
>     var child;
>     child = exec("kill `lsof -t -i:4723`", function (error, stdout, 
> stderr) 
>    {
>     sys.print('stdout: ' + value);
>     sys.print('stderr: ' + stderr);
>     if (error !== null) {
>     console.log('exec error: ' + error);
>     }
>     });
> it works fine but it is only for port 4723 and i want to take variabe say 
> portnumber and then use **kill `lsof -t -i:$portnumber`**  instead of 
> **kill `lsof -t -i:4723`**  and the value for the variable portnumber is 
> obtained from code file
>
> How to do this ?
>
>
>  
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to