• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Get Wan ip 2016-10-18

No permission to download
Get External ip from ipify.org with curl and parse to progress 4gl.

DEF VAR VRUN_FILE AS CHAR NO-UNDO.
DEF VAR VRESULT AS LONGCHAR NO-UNDO.

ASSIGN VRUN_FILE = "C:\curl\curl -X GET -v https://api.ipify.org?format=json > c:\result.txt".
OS-COMMAND SILENT VALUE(VRUN_FILE).

COPY-LOB FROM FILE "c:\result.txt" TO VRESULT NO-ERROR.

VRESULT = REPLACE(VRESULT, CHR(123) , "").
VRESULT = REPLACE(VRESULT, '"' , "").
VRESULT = REPLACE(VRESULT, '}' , "").
VRESULT = ENTRY(2,VRESULT,":").

MESSAGE STRING(VRESULT)VIEW-AS ALERT-BOX INFO BUTTONS OK.