On Windows it's pretty easy. On MacOS it's a little trickier. Here's a function I wrote to get the default connection, which contains methods for getting the network adapters for Windows and MacOS. Enjoy:
FUNCTION getDefaultNetwork pMode -- leave pMode empty for just IP and MAC info. Pass "Detail" to get more info IF the platform contains "WIN" THEN set hideconsolewindows to true put "netsh interface ip show config" into tShellCommand TRY put shell(tShellCommand) into tDefaultAdapter CATCH tError return tError END TRY -- if pMode is detail just return these results IF pMode is "Detail" THEN return tDefaultAdapter -- get the default adapter and Gateway IP addresses put lineoffset("IP Address:", tDefaultAdapter) into tIPAddressLine put word -1 of line tIPAddressLine of tDefaultAdapter into tLocalIPAddress put lineoffset("Default Gateway:", tDefaultAdapter) into tGWAddressLine put word -1 of line tGWAddressLine of tDefaultAdapter into tGWIPAddress -- get the default adapter and gateway MAC addresses put "ipconfig /all" into tShellCommand TRY put shell(tShellCommand) into tConfigData CATCH tError return tError END TRY put lineoffset(tLocalIPAddress, tConfigData) -3 into tLocalMACLine put word -1 of line tLocalMACLine of tConfigData into tLocalMACAddress put "arp -a" into tShellCommand TRY put shell(tShellCommand) into tArpData CATCH tError return tError END TRY put lineoffset(tGWIPAddress, tArpData) into tGWMACAddressLine put word 2 of line tGWMACAddressLine of tArpData into tGWMACAddress put tLocalIPAddress && tLocalMACAddress & cr & \ tGWIPAddress && tGWMACAddress into tCurrentAdapterInfo ELSE -- first we need to get the default adapter put "route get default" into tShellCommand TRY put shell(tShellCommand) into tDefaultAdapter CATCH tError return tError END TRY put lineoffset("Interface: ", tDefaultAdapter) into tInterfaceLine IF tInterfaceLine = 0 THEN return "ERROR: No default interface found!" END IF -- now we need the detail of the interface put word 2 of line tInterfaceLine of tDefaultAdapter into tDefaultInterface put "ipconfig getpacket " & tDefaultInterface into tShellCommand TRY put shell(tShellCommand) into tInterfaceDetail CATCH tError return tError END TRY -- if we didn't specifically ask for the interface and router MAC addresses, return here IF pMode is "Detail" THEN return tInterfaceDetail -- now we get the interface MAC address put lineoffset("chaddr", tInterfaceDetail) into tInterfaceMACLine put word -1 of line tInterfaceMACLine of tInterfaceDetail into tDefaultMACAddress -- and the IP address put lineoffset("yiaddr", tInterfaceDetail) into tInterfaceIPLine put word -1 of line tInterfaceIPLine of tInterfaceDetail into tDefaultIPAddress -- next we get the router IP address put lineoffset("router (ip_mult): ", tInterfaceDetail) into tRouterLine put word 3 of line tRouterLine of tInterfaceDetail into tRouterIPAddress put char 2 to -2 of tRouterIPAddress into tRouterIPAddress -- next we get the MAC address of the router interface put "arp " & tRouterIPAddress into tShellCommand TRY put shell(tShellCommand) into tArpReply CATCH tError return tError END TRY put word 4 of tArpReply into tRouterMACAddress -- finally we return the MAC addresses of the default interface and the router interface put tDefaultIPAddress && tDefaultMACAddress & cr & \ tRouterIPAddress && tRouterMACAddress into tCurrentAdapterInfo END IF return tCurrentAdapterInfo END getDefaultNetwork Bob S > On Apr 13, 2021, at 05:27 , Tiemo via use-livecode > <use-livecode@lists.runrev.com> wrote: > > Thanks Matthias and Andre for pointing out for these options > > Tiemo > > > -----Ursprüngliche Nachricht----- > Von: use-livecode <use-livecode-boun...@lists.runrev.com> Im Auftrag von > Andre Garzia via use-livecode > Gesendet: Dienstag, 13. April 2021 11:38 > An: How to use LiveCode <use-livecode@lists.runrev.com> > Cc: Andre Garzia <an...@andregarzia.com> > Betreff: Re: Offtopic: Can anybody create a small DLL for me? > > Tiemo, > > Maybe it is possible to parse the result of > > shell(“ipconfig /all”) > > To get the same information. I’m not sure which information you’re collecting > but I just run that on my windows and I could see every interface and the > info about them. > > Best > A _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode