ibm-midrangerpglenslookup

Implement NSLOOKUP into a program


I need to check if a domain exist in an RPGLE (or CLLE) program.

I can use in command line, example:

nslookup hostname(google.it)

There's a way to use the same command into a RPGLE (or CLLE) program? How can I check the result) Or alternatively is there an API?


Solution

  • You can redirect the output to a file like this

    crtpf qtemp/stdout rcdlen(240)
    ovrdbf stdout qtemp/stdout
    ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE(STDOUT) LEVEL(*JOB)
    NSLOOKUP HOSTNAME(google.it)
    rmvENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) LEVEL(*JOB)
    

    but maybe DIG output is easier to read by program (and NSLOOKUP is deprecated)

    crtpf qtemp/stdout rcdlen(240) 
    ovrdbf stdout qtemp/stdout
    ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE(STDOUT) LEVEL(*JOB)    
    DIG HOSTNAME(google.it)
    rmvENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) LEVEL(*JOB)
    

    Your you can just resolve with gethostbyname like there