This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Obtain IP address of Logic Machine
#1
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
Reply
#2
Code:
require('ifinfo')
ip = ifinfo().eth0.inetaddr
Reply
#3
(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?
Reply
#4
This is an internal library used by system config, so it's not documented. Our documentation is available at http://openrb.com/docs/
Reply
#5
(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.
Reply


Forum Jump: