DEF TEMP-TABLE host-info FIELD host-ip AS CHAR FORMAT "X(15)" FIELD host-name AS CHAR FORMAT "X(30)" INDEX host-name IS PRIMARY host-name. def var strg as char. def var first-space as int. def var ip-string as char. def var ip-decimal as decimal. INPUT THRU "cat /etc/hosts". import-hosts: REPEAT: IMPORT UNFORMATTED strg. IF TRIM(strg) = "" OR TRIM(strg) BEGINS "#" THEN NEXT import-hosts. /* (overkill) */ ASSIGN strg = TRIM(REPLACE(strg,"~t"," ")) strg = TRIM(REPLACE(strg,"~r"," ")) strg = TRIM(REPLACE(strg,"~n"," ")) strg = TRIM(REPLACE(strg,"~E"," ")) strg = TRIM(REPLACE(strg,"~b"," ")) strg = TRIM(REPLACE(strg,"~f"," ")) first-space = INDEX(strg," ") ip-string = TRIM(SUBSTR(strg,1,first-space)). ASSIGN ip-decimal = DEC(REPLACE(ip-string,".","")) NO-ERROR. IF ERROR-STATUS:ERROR THEN NEXT import-hosts. /* invalid ip address */ CREATE host-info. ASSIGN host-info.host-ip = ip-string. IF first-space > 0 THEN ASSIGN strg = TRIM(SUBSTR(strg,first-space)) host-info.host-name = TRIM(SUBSTR(strg,1)). ELSE DO: DELETE host-info. NEXT import-hosts. END. IF INDEX(host-info.host-name," ") > 0 THEN ASSIGN host-info.host-name = SUBSTR(host-info.host-name,1,INDEX(host-info.host-name," ")). END. for each host-info: INPUT THRU VALUE("lpstat -a " + host-name). IMPORT UNFORMATTED strg. disp host-info.host-name strg format "x(30)" with down. end.