Question
· Sep 20, 2018

fetch ip address of cache installation

I'm using cache  win10-x64  version 2017.2.1.801

I want to uniquely identify the installation of cache, and from that create a meaningful unique folder names to store files. 

so to generate \192-168-1-100\KEVDEV\testfolder \ and \192-168-1-5\LIVE\testfolder\

so in this case, I could- use the IPaddress and thesecond part of $SYSTEM (cache instance name) - at least this way, I can instantly see where it came from with little risk of overwriting between cache instance.

looking into the options, I found

generate a unique random folder name (not helpful when trying to understand the contents)

w $SYSTEM - gives DESKTOP-VN0HNSP:KEVDEV (not unique enough ?)

w $SYSTEM.INetInfo.LocalHostName()  - generates DESKTOP-VN0HNSP -this is the first part of $SYSTEM (could change by renaming the computer)

w $SYSTEM.INetInfo.EthernetAddress() - generates 000C292678A - ie mac address (liable to change if the card goes down - what happens on two network cards being installed ?)

w $SYSTEM.INetInfo.HostNameToAddr($SYSTEM.INetInfo.LocalHostName())  - generates 10.0.0.49 (could change, but unlikely - certainly in our network)

the last one generates the IPaddress that the system is installed on but relies on the LocalHostName() to get that number

is there any risks associated with the LocalHostName() call.

can I obtain the IPAddress any other way without using the LocalHostName()  ?

I'm using windows today, but is there any issues if we suddenly swap to linux ? - being a $system call, I assume not

suggestions please.

kevin

Discussion (10)3
Log in or sign up to continue

Kevin

You can also use a Command Pipe (docs) and read directly from your OS using IPconfig  (on Windows) or ifconfig (in Linux/ Unix)

You just do the usual OPEN + USE and READ whatever comes back.

As an example a handcrafted ping routine

zping ;
 k empty
 s pipe="|CPIPE|"
 close pipe
 s ping="ping 10.10.12."_p
 open pipe:(ping):10 w $t," ",p,!
 for  {
 use pipe read line
 use 0
 set empty=$s($l(line):0,1:$i(empty)) q:empty>3
 write:empty<2 line,!
 }

Hello Kevin,

if I anderstand you correctly, several your Cache systems (development, life, ...) will store their files on a third server (possibly on a file server) and you want to put the files from each (source) Cache (instance) into a different (target) folder, where the folder name being the "name" of the source Cache system - am I correct?

If yes, I think, your best choice ist:

...\hostNameOfCache\instanceNameofCache...

or, as John Murray suggested

...\GUIDofCacheInstance...

or just a fixed string like

...\kevinNotebook(development)...

You can put (John's) GUID or my "fixed string"
in a (possibly system) Global like ^%Zconfig("path")=...

Why?
Things like MAC- or IP-Addresses can change more often then you think. Especially IP-Addresses will change, hence are there DNS servers.

On the other hand, it's uncommon to change host- or instance names (of Cache or of whatever installation).

Your IP-Address preference has an other downside too. Many servers have more then one IP-Address (and if they do not have one today, maybe tomorrow!).

If you persist to take the systems IP-Address, here is, what you wanted:

set iplist = $system.INetInfo.GetListOfConfiguredInterfaces(0)
for i = 1:1:$listlength(iplist) zw $list(iplist,i)

Regards and
have a nice day
Julius