Hello ,
I have created a file that have 3 IP from my router
10.0.0.1
192.168.1.5
8.8.8.8
now I want to save each IP in a different variable?
how do I do this?
so I will have
wire 10.0.0.1
local 192.168.1.5
ddns 8.8.8.8
?
I have try to use
:pick
but I don’t allwayes know the length of the IP ,
is there any other way? smarter ?
I can put after any IP a “!” so I will search from start to “!”
can I do this?
you can name them in the file like this
wire 10.0.0.1
local 192.168.1.5
ddns 8.8.8.8
do this
:local fi [/file get value-name=contents “filename.txt”]
:local ip1 [:pick $fi 4 ([:find “local”])]
:local ip2 [:pick $fi ([:find “local”]+6) ([:find “ddns”])]
:local ip3 [:pick $fi ([:find “ddns”]+5) ([:len $fi])]
the idea is “find” is search for the string or character and send back it’s position in the array , we need to add the length of the string itself with space so “local” is 5 digits + 1 for space =6 , while ddns is 4 digits + 1 for space=5