I'm attempting to return the IP address of the Windows machine into a node process using child.exec. Simple command lines seem to work but anything vaguely complex fails - anyone got any suggested resolutions / explanations for why it's failing?
Code as follows:
var exec = require('child_process').exec;
var ifconfig = (process.platform !== undefined && process.platform !== 'win32') ? 'ifconfig eth0' : 'ping -4 %COMPUTERNAME%';
var child = exec(ifconfig, function(err, stdout, stderr) {
if (err) throw err;
else console.log('child', stdout);
});
var FYI 'ping %COMPUTERNAME%' works, 'ping %COMPUTERNAME% -4'fails.
Also FYI, original suggestion for CLI code from here:
http://ayesamson.com/2011/06/13/get-ip-address-from-windows-command-line/
Ta
N