Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

usage of unix sort, mail and return code passing from COBOL to script

Status
Not open for further replies.

amar9

Programmer
Nov 23, 2003
9
US
Hi,

Greetings. I am working on migration project which involves migration of cobol application from VAX/VMS platform to HP UNIX. I have couple of doubts while writing korn shell scripts. Could you let me know if you have information regarding how to handle the following tasks.

1. Unix Sort:

I would like to exclude some of the records while writing data into output file while sorting.
For example: If 1st byte in the record equal to 'H' exclude this record from sorting and do not write this record into output file. Please let me know how to handle this using unix sort command.

2. Unix Mail:

I would appreciate any kind of info on using mail command in korn shell to send the the text to different users using distribution list.

3. I want to pass return code from a MF COBOL program to unix korn shell script for validation purpose in the script. Please let me know how to handle this.

Thanks in advance for your help.

Regards,
Amar
 
1. Unix sort by itself cannot do that as far as I know, but it's easy to filter out things using the search program
Eg
Code:
egrep -v '^H' filename | sort
The first part of the command finds all the lines which don't begin with an H, and passes them onto the sort command.

Pipes, that's the | character in the above, are common in unix scripting. A pipe joins the output of the left hand command to the input of the right hand command.

2. pass

3. Experiment with the following to discover what exit status values are present
Code:
./my_cobol_prog
echo status is $?
$? contains the exit status of the previous command. You can then use this in various ways to determine what your ksh script does next.

--
 
Hi Amar,

1. What kind of file? Unix's sort can sort only plain text files.

2. Don't know HP/Ux. In Sco you can:
mail `more text_file_containing_user_list` < text_file_to_send
Whatch out for the backslashes. For more info: man mail

3. See answer in &quot;COBOL General discussion&quot; forum

Hope it helps

Theophilos.
 
Hi Salem, theotyflos,

Thank you for your quick replies.

1) The egrep command gave the expected result. Thank you Salem.

2. Not yet tried

3. About passing return-code from cobol.

in cobol

move nnn to RETURN-CODE
STOP RUN.

where nnn is a numeric valuee <=255)

in script:

rc = $?
echo $rc

Once again, thanks for your information.

Regards,
Amar


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top