[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

SPAWN Subprocess auditing, I/O redirection?

» close window

The Question is:

 
I need to create a shared object that can be accessed by Oracle to run system
 commands.  The key here is that everything about the command must be logged.
 The windows implementation allows me to redirect "stdout" to a file.  Then I
 can use "cout" or "pri
ntf" to log the command and the time it began and ended.  Then, using the C
 "system" function, I can run the command and any output from that command also
 gets logged to the logfile.  In VMS, however, the scope of the redirection of
 SYS$OUTPUT does not ex
tend back into the program.  After the LIB$SPAWN command to redirect SYS$OUTPUT
 to a file, the LIB$SPAWN command exits and returns to the program.  The
 remaining lines of code do NOT use the redirected SYS$OUTPUT.  (I have
 attempted to do this with LIB$SE
T_LOGICAL also but could not make that work)
 
I would like to know how to redirect SYS$OUTPUT in the begining of a C program
 and use that redirection for the entire program (including "printf" output).
 
Thank You,
david
 
 


The Answer is :

 
  Please see topic (5753) for a related discussion of I/O redirection.
 
  Use image accounting or OpenVMS security auditing, as these tools can
  likely log the various times of interest for you automatically.
 
  Alternatively, create subroutine which creates a process running DCL,
  and then pass commands to it via a mailbox, and log the required time
  and associated information.
 
  If you want a hack, create a small DCL command procedure that executes
  the designed command in the target process context -- the command can
  be passed via parameter -- and that also logs the desired information.
  (Or you could pass in the "prefix" and "suffix" commands around the
  target command via the mailbox.)
 
  The C system call and lib$spawn create new subprocesses, and the process
  context is typically entirely local to the new subprocess, unless sharing
  is explicitly requested.  You can configure the subprocess to run entirely
  asynchronous to the parent, or you can have the parent wait for the
  subprocess to complete.
 

answer written or last revised on ( 13-FEB-2001 )

» close window