From: briggs@encompasserve.org
Sent: Friday, September 12, 2003 8:18 AM
To: Info-VAX@Mvb.Saic.Com
Subject: Re: Mailboxes and SYS$OUTPUT

In article <ae38b.41$K_3.22054@news.uswest.net>, "Michael D. Ober" <obermd-@-alum-mit-edu-nospam> writes:
> Does anyone have sample code that creates a temporary mailbox and then
> redirects the SYS$OUTPUT of a spawned subprogram to that mailbox?
$ type backup_to_mbx.for
        options         /extend_source

        implicit        none

        integer         lib$spawn, sys$crembx, lib$get_foreign

        integer *2      chan

        integer         status

        character *63   disk
        integer *2      disk_l

        status = lib$get_foreign ( disk, 'What disk? ', disk_l )
        if ( .not. status ) then
            type *, 'Failed to retrieve disk selection'
            call sys$exit ( %val(status) )
        end if

        status = sys$crembx ( %val(1), %ref(chan), %val(8192), %val(32768),,,
        2                     'backup_mbx',, )
        if ( .not. status ) then
            type *, 'Failed to create mailbox'
            call sys$exit ( %val(status) )
        end if

        status = lib$spawn ( 'backup /log /block=8192 /image /ignore=interlock ' //
        1                    disk(1:disk_l) // ': backup_mbx:. /save' )
        if ( .not. status ) then
            type *, 'Spawn failed'
            call sys$exit ( %val(status) )
        end if

	! Separate external program that reads from the mailbox omitted
	! I think I was piping it elsewhere using rcp or some such.

        end