HP OpenVMS Systems

ask the wizard
Content starts here

C/C++ log files, stdout, I/O redirection?

» close window

The Question is:

How can I redirect sys$output from within a C++ process. I have a process that
 generates a new output file for stdout (printf statements) each day. This is
 done with c/c++ freopen function. This works fine for the stdout assignment
 for printf statements.
But the process also has a system call that submits a DCL com procedure to be
 executed. Basically as follows:
where the string StartFtpCmd is
 static char    *StartFtpCmd = "Submit/Log=VISLFML:FMCOILLOGS_FTP.OUT/NoPrint
 VISU:FMLOGS.Com"; // used in system call
When this com file is executed there is an entry made in the original/first
 process log file where the job is entered into a system que. This entry is
 always in the first log file that was opened when the process was first
 started. It looks like sys$outpu
t is still writing to this original file (still has this file opened???) even
 though stdout is writing to another file (same name but different version
Below is a sample of the output in the file that comes from the system call.
Job FMLOGS (queue SYS$BATCH, entry 841) started on SYS$BATCH
It looks to me like the process is able to control whare stdout goes but at the
 VMS system level I am not able to redirect sys$output for the process. VMS
 started the process with sys$output directed the original output file when the
 process started and d
oing a call to freopen has no effect on sys$output. I tried a call to
 lib$set_logical(sys$output,&Logfile) but this did not seem to work
I don't know if what I am asking is clear or not but I would appreciate some
 help with this.

The Answer is :

  Once created and running, batch processes generally do not prefer
  that the target output log file be altered.
  The OpenVMS Wizard would strongly recommend the use of an
  explicitly-created and application-specific log file, rather than
  attempting to peridically redirect SYS$OUTPUT (stdout).  This is far
  simpler, and far easier to maintain and to explain.
  For details on creating output files with RMS sharing enabled, please
  see the OpenVMS FAQ.
  The OpenVMS Wizard would encourage use of $sndjbc, and not the use of
  a lib$spawn of the SUBMIT command.
  There are FTP client APIs available for various platforms, and the
  OpenVMS Wizard expects that one of these has been ported to OpenVMS.
  (The FTP protocol is itself not particularly complex.)
  If you wish to use FTP from within DCL, please use COPY/FTP.
  Please upgrade to supported OpenVMS and TCP/IP Services and C++ releases,
  and please apply any available mandatory ECO kits for the products.
  Without details on exactly what the code involved is doing with the
  freopen and other logfile-related processing, the OpenVMS Wizard
  cannot determine exactly what is occuring here.

answer written or last revised on ( 12-AUG-2002 )

» close window