Logic Machine Forum
Obtain IP address of Logic Machine - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Obtain IP address of Logic Machine (/showthread.php?tid=1135)



Obtain IP address of Logic Machine - baggins - 14.12.2017

Hi,

In some of my scripts it would be useful to know the IP address of the Logic Machine on which they run.
Now I use something I found somewhere:


Code:
require('socket')
local s = socket.udp()
s:setpeername("192.168.1.1",80)
local ip, _ = s:getsockname()
log(ip)


I don't know how it works, but it works (and does not require a connection to the IP address in the script. As a matter of fact that IP address is irrelevant).
Is there a more elegant solution?
Thanks


RE: Obtain IP address of Logic Machine - admin - 15.12.2017

Code:
require('ifinfo')
ip = ifinfo().eth0.inetaddr



RE: Obtain IP address of Logic Machine - baggins - 15.12.2017

(15.12.2017, 07:10)admin Wrote:
Code:
require('ifinfo')
ip = ifinfo().eth0.inetaddr

Thanks, very neat!

Now where can one find documentation on this kind of stuff?


RE: Obtain IP address of Logic Machine - admin - 15.12.2017

This is an internal library used by system config, so it's not documented. Our documentation is available at http://openrb.com/docs/


RE: Obtain IP address of Logic Machine - baggins - 15.12.2017

(15.12.2017, 10:45)admin Wrote: This is an internal library used by system config, so it's not documented. Our documentation is available at http://openrb.com/docs/

Thanks.