So, I have been working on an API which allows me to assign additional addresses to computers. And No I have a moment of confusion:
function internal.dns.loadHosts()local HOST_FILE_LOC = os.getenv("HOST_FILE_LOC")
print(HOST_FILE_LOC)--Prints /usr/misc/hosts.txt
assert(HOST_FILE_LOC,"Missing environment variable: HOST_FILE_LOC pointing to a file used for storing dns mamppings ")if(filesystem.exists(HOST_FILE_LOC))thenlocal hostFile = io.open(HOST_FILE_LOC)
print(serialization.unserialize(hostFile:read("*all")))--prints a tablelocal hosts
hosts = serialization.unserialize(hostFile:read("*all"))
print(hosts)-- prints nil
hostFile:close()return hosts --Return a table of hosts, if successfulelsereturnnil--Return nil if hostfile doesnt existendend
Why is it that these two seemingly same calls return different values. one is table other is nil?
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
So, I have been working on an API which allows me to assign additional addresses to computers. And No I have a moment of confusion:
Why is it that these two seemingly same calls return different values. one is table other is nil?
Link to post
Share on other sites