[fpc-pascal] How to list IP and MAC of network adapters on Windows?

Travis Siegel tsiegel at softcon.com
Fri Sep 10 14:54:58 CEST 2021


I don't know how much it will help, but windows has a similar command to 
linux ifconfig, only on windows it's called ipconfig.

Hope this helps.


On 9/10/2021 3:03 AM, Bo Berglund via fpc-pascal wrote:
> Is there a way to enumerate the active adapters on a Windows computer with their
> IPv4 and MAC addresses?
>
> I am trying to convert a Linux reporting script to Windows, but I have a hard
> time finding a suitable Windows command. The script uses common Linux commands
> and tools to get the eth0 and wlan0 data (IPv4 and MAC addresses) and then to
> POST it to my website mailer (php script) via curl. See below.
>
> I have curl on Windows too so once the data are found the same command can be
> used here as well, but the network info extraction seems to be a lot harder.
>
> So I figured I could write a small FPC command line tool to extract this
> information and use it in the batch file.
>
> But is there some such call available in FPC or standard packages like LNet or
> similar?
>
> On Linux I can do this in the bash script:
>
> MyName=$(hostname)
> IPAddr=$(ifconfig eth0|grep "inet "|sed 's/ *inet //;s/ .*//')
> IPAddrWiFi=$(ifconfig wlan0|grep "inet "|sed 's/ *inet //;s/ .*//')
> IPMac=$(ifconfig eth0 | grep -Eo ..\(\:..\){5})
> IPMacWiFi=$(ifconfig wlan0 | grep -Eo ..\(\:..\){5})
>
> I don't believe there is a similar command line way on Windows, so therefore I
> ask for a FPC way of getting it.
>
>


More information about the fpc-pascal mailing list