Reputation: 925
I want to concatenate this string called test
inside the URL but it doesn't seem to work:
test = "1.1.1.1"
local geoip = io.popen("wget -qO- 'https://api.ipgeolocationapi.com/geolocate/' .. test .. '":read():match'"name":"(.-)"')
print(geoip)
I got this error:
lua: hello.lua:3: ')' expected near ':'
I also tried doing like this way but I got the same error:
test = "1.1.1.1"
command = "wget -qO- https://api.ipgeolocationapi.com/geolocate/" .. test
local geoip = io.popen(command:read():matchname":"(.-)"')
print(geoip)
The url should append the test string. Any idea how to achieve this ?
Upvotes: 1
Views: 440
Reputation: 4617
You need to fix your quotes and parentheses; your test
is inside a string literal and read
and match
are inside io.popen
call:
local geoip = io.popen ("wget -qO- 'https://api.ipgeolocationapi.com/geolocate/" .. test .. "'"):read ():match '"name":"(.-)"'
Upvotes: 3