process.env.COMPUTERNAME
deneyebilirsin.Kendi cihazımda çalıştırıyorum zaten ama çıktı Object Object oldu.require('os').networkInterfaces()
objesi içinde cihaz cihaz olması lazım ama bunu public bir sunucuda çalıştıramazsın, cloud hosting ve lokalde çalışır sadece. Güvenlik açığından ötürü kapatıyorlar.
Burdan webhooka gönderiyorum ben bilgileri o yüzden sadece mac adressleri lazım.@behzat_c zaten o bir obje,console.log
ile çıktısına bakıp ona göre incelemen lazım.
public static string macAdresses() // grab mac adresses
{
string s = "";
int num = 1;
foreach (NetworkInterface networkInterface in NetworkInterface.GetAllNetworkInterfaces())
{
if (networkInterface.OperationalStatus == OperationalStatus.Up)
{
s += "\n";
s += num.ToString() + "- ";
s += networkInterface.GetPhysicalAddress().ToString();
++num;
break;
}
}
s += "\n";
s += num.ToString() + "- ";
++num;
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
s += "\n";
s += num.ToString() + "- ";
s += nic.GetPhysicalAddress().ToString();
++num;
}
return s;
}
Tamam işte objeyi parse edip alabilirsin, listeden map metodu ile alırsın.Buradan webhooka gönderiyorum ben bilgileri o yüzden sadece mac adresleri lazım.
console.log
layıp bir sonucu gör. İlla ki satır satır kodu mu yazayım? O zamanTabi ben JS'ye dün başladığım için nasıl yapacağımı bilemiyorum. Yardımınızı bekliyorum.
console.log
içinde yazıp bir göster ona göre bir kod yazayım.Tamam işte objeyi parse edip alabilirsin, listeden map metodu ile alırsın.console.log
layıp bir sonucu gör. İlla ki satır satır kodu mu yazayım?
O zamanconsole.log
içinde yazıp bir göster ona göre bir kod yazayım.
Info: Start process (21:46:12)
{
'Wi-Fi': [
{
address: 'fe80::a42e:b0cf:7e33:5a8b',
netmask: 'ffff:ffff:ffff:ffff::',
family: 'IPv6',
mac: '34:46:1b:2e:26:5b',
internal: false,
cidr: 'fe80::a42e:b0cf:7e33:5a8b/64',
scopeid: 13
},
{
address: '192.168.1.30',
netmask: '255.255.255.0',
family: 'IPv4',
mac: '34:46:1b:2e:26:5b',
internal: false,
cidr: '192.168.1.30/24'
}
],
'Loopback Pseudo-Interface 1': [
{
address: '::1',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
family: 'IPv6',
mac: '00:00:00:00:00:00',
internal: true,
cidr: '::1/128',
scopeid: 0
},
{
address: '127.0.0.1',
netmask: '255.0.0.0',
family: 'IPv4',
mac: '00:00:00:00:00:00',
internal: true,
cidr: '127.0.0.1/8'
}
]
}
Info: End process (21:46:13)
const object = require('os').networkInterfaces();
const macAddresses = [];
Object.keys(object).forEach(key => {
object[key].forEach(item => {
if (item.mac != null) macAddresses.push(item.mac);
});
});
const macAddressesStr = macAddresses.join(",");
Konsola nasıl yazdıracağım bunu@behzat_c şöyle gelmesi lazım virgülle ayrılmış olarak. Compile etmeden yazdım hata olabilir.
JavaScript:const object = require('os').networkInterfaces(); const macAddresses = []; Object.keys(object).forEach(key => { object[key].forEach(item => { if (item.mac != null) macAddresses.push(item.mac); }); }); const macAddressesStr = macAddresses.join(",");
Konsola nasıl yazdıracağım bunu?
console.log(macAddressesStr);
Virgül yerine alt alta olsa olmaz mı ve MAClerin arasında ki " : " işareti olmasa?console.log(macAddressesStr);
Bu sitenin çalışmasını sağlamak için gerekli çerezleri ve deneyiminizi iyileştirmek için isteğe bağlı çerezleri kullanıyoruz.