I'm writing a command line program to control certain hardware devices. I can hardcode or have in a config file the IP addresses for the devices, if I know that info. If I don't? Then I run an 'nmap' command and look for the devices. But why should I, a human, have to do any work like that? Bah! I want my program to obtain this information at runtime, automatically, and "don't make me think".

One thing that might make it tough is nmap must run sudo to report the desired information. (To my knowledge; I'm no networking expert.) The exact command is:

sudo nmap -sn 192.168.11.0/24  |ack -B2 "Philips"

The IP address is printed two lines before the name match (ack is "better than grep"). Typical nmap output is a series of chunks of text like this:

Nmap scan report for 192.168.11.10
Host is up (0.00033s latency).
MAC Address: 00:17:88:4D:97:4D (Philips Lighting BV)

I don't see any D std.* libraries that do this. Are there a Dub packages I should look at?


Reply via email to