1

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?

Nifriz
  • 1,033
  • 1
  • 10
  • 21

1 Answers1

3

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

Mike
  • 1,274
  • 10
  • 24
nfgl
  • 2,812
  • 6
  • 16