1. 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

Get Wan Ip

  1. Hikmet_Alemdaroglu
    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.