On Saturday, 22 January 2022 at 22:44:31 UTC, forkit wrote:


and here is how to get the ip (depending on the formatting of your output of course)

// ---
module test;

import std;

void main()
{
auto result = execute(["bash", "-c", "nmap -sn 192.168.11.0/24 | ack -B2 \"Philips\""]);

    string ip;

    if(canFind(result.to!string, "Host is up"))
    {
        writeln("Host is up");

        string str = result.to!string.chop;
        ip = str[ (indexOf(str, "for Philips (") + 10)..$-4 ];
        writeln(ip);
    }
    else
        writeln("Host not found.");
}

// ----

Reply via email to