node.js - Get all network interfaces with node -
how network interfaces , ip address, mac addresses, state, , it's master interface.
os.networkinterfaces()
won't work, because doesn't report interfaces down, or don't have ip addresses, , doesn't return state (up
/down
/etc) or master interface.
var shell = require('shelljs'); var interfacecard = shell.ls('/sys/class/net');
this interfacecard has list of network interfaces
output
[ 'eth0', 'eth1', 'lo', **stdout: 'eth0\neth1\nlo\n',** stderr: null, code: 0, cat: [function: bound ], exec: [function: bound ], grep: [function: bound ], head: [function: bound ], sed: [function: bound ], sort: [function: bound ], tail: [function: bound ], to: [function: bound ], toend: [function: bound ], uniq: [function: bound ] ] interfacecard=interfacecard.**stdout**.split('\n'); interfacecard = eth0, eth1, lo
Comments
Post a Comment