Created On:  2010-03-17

Problem:

I want my COBOL application to be able to send a message to a UNIX user (To inform, for example, that a specific event occurred).  How do I proceed?

Resolution:

Code is pasted and attached to this KB.

Note it sends a message using the UNIX write command using as the destination user an environment variable named here $DESTUSER ( for convenience of the test,: export DESTUSER=$USER launch the compiled sample


       working-storage section.
       01 MUcmd.
           02 filler            pic x(5) value "write".
           02 filler            pic x    value spaces.
           02 uid               pic x(10) value "$DESTUSER".
           02 filler            pic xxx  value  "<<!".
           02 filler            pic x    value x"0A".
           02 msg               pic x(100).
           02 filler            pic x    value x"0A".
           02 filler            pic x    value "!".
           02 filler            pic x    value x"00".

       procedure division.
           move "This message was sent from a COBOL program using the
      - "Unix write command" to msg
           call "system" using MUcmd

Incident #2438750