Skip to main content

I am looking for a way to validate email domains from COBOL in a interactive data entry environment.  In my application users will enter email addresses provided by our customers.  The domain of the email address provided is not always valid.  I am running Server Express on top of HPUX 11.32.  I am familiar with the nslookup command and have written a test program to execute this command calling the SYSTEM subroutine.  I can't seem to get the command to pass back to COBOL a return code and anything for that matter to designate whether the command was successful or not.  Anyone have any ideas how to validate email domain names from COBOL?  Thanks in advance.

I am looking for a way to validate email domains from COBOL in a interactive data entry environment.  In my application users will enter email addresses provided by our customers.  The domain of the email address provided is not always valid.  I am running Server Express on top of HPUX 11.32.  I am familiar with the nslookup command and have written a test program to execute this command calling the SYSTEM subroutine.  I can't seem to get the command to pass back to COBOL a return code and anything for that matter to designate whether the command was successful or not.  Anyone have any ideas how to validate email domain names from COBOL?  Thanks in advance.

Hi Don,

You mentioned that you've tried to call the SYSTEM routine. Calling this routine in Server Express requires that you pass a null terminated string (a string where the command is followed by a low-values or X'00' character.)

You may want to take a look at the following Micro Focus Knowledge Base article, which demonstrates one technique for setting up the null terminated string, and shows retrieving a return code:

community.microfocus.com/.../6537.invoke-a-unix-command-from-within-cobol-using-call-system-and-retrieve-return-code.aspx

If you are using Micro Focus COBOL syntax, another option for creating a null terminated string is to use a Z before your literal, for example:

MOVE Z"ls -l"   to ws-command


I am looking for a way to validate email domains from COBOL in a interactive data entry environment.  In my application users will enter email addresses provided by our customers.  The domain of the email address provided is not always valid.  I am running Server Express on top of HPUX 11.32.  I am familiar with the nslookup command and have written a test program to execute this command calling the SYSTEM subroutine.  I can't seem to get the command to pass back to COBOL a return code and anything for that matter to designate whether the command was successful or not.  Anyone have any ideas how to validate email domain names from COBOL?  Thanks in advance.

Don, when you CALL SYSTEM() or system() the only thing returned is the status for the CALL, no data if any kind is returned. If you want the output of the the command you can define a File as an input pipe from the command   When you open the file the command runs when you read from the file the STDOUT Of the command is returned in the record   If you define the file as line sequential then one line of output is returned for each READ.