Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

how to print to screen when com-procedure is run with /output ?

 
SOLVED
Go to solution
Scotty HD
Frequent Advisor

how to print to screen when com-procedure is run with /output ?

I have command-procedure calling a c-program.

the c-program has a loop for 1000 where it does some work. i run command-procedure like
@work/output=work.log

all the detailed output of the work.com goes to work.log which is correct. but for every 20 entries processed, i want a message like "processed 20 elements" to be displayed on the screen. how to do this ?

expected output,
$@work/output=work.log
processed 20 files
processed 40 files
processed 60 files
processed 80 files
$

what changes to do in the c-prgram ?
after every 20 entries, should the c-program call some com procedure for the printing work ?

Scotty
8 REPLIES 8
Jan van den Ende
Honored Contributor
Solution

Re: how to print to screen when com-procedure is run with /output ?

Scotty,

one way: open an extra output channel to the TT device (logical name: tt) and write to that
another way: write to SYS$ERROR
or: (as you suggested) spawn a DCL procedure, with the number as parameter, and have the DCL write that number + your fixed text.
If it needs "a lot" (whatever you define that to be) of invcations, DO realise that each SPAWN creates another supprocess, which is quite expensive in VMS (unlike Unices).

I am sure there are a gazillion other ways...

PS. you may well want to also find a way to turn your progress reporting OFF and ON again.

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Scotty HD
Frequent Advisor

Re: how to print to screen when com-procedure is run with /output ?

thanks for help.

#open an extra output channel to the TT device (logical name: tt) and write to that
do you mean i do a assign to tt: and get a channel number ?
i use printf but that put data to sys$output always i think. what other print call should i use so that i can tell it where to print?

#write to SYS$ERROR
When i try this using a single com-procedure it works. but it does not work in case of,
com1->c_prg->com2.
in com2, i find sys$error is same as sys$output. all output goes to work.log.

any comment.?

Scotty
Scotty HD
Frequent Advisor

Re: how to print to screen when com-procedure is run with /output ?

i did some test,

Com1->c_prg->com2
i got this working. i use sys$command, it is set to terminal in com2.

from your reply, i want
Com->c_prg
with c_prg printing progress. this way i can avoid the costly subprocess creation.

from c program, how to print to sys$command ?
lib$put_output and printf always use sys$output, correct?

Scotty
abrsvc
Respected Contributor

Re: how to print to screen when com-procedure is run with /output ?

Why not just open the logfile directly from the program and write the message every 20 files to the standard output? Either way a second "file" needs to be opened. Why redirect the standard output and then open another channel to the screen. Why not just open/write to the logfile directly?

Dan
RBrown_1
Trusted Contributor

Re: how to print to screen when com-procedure is run with /output ?

Yes, printf always uses sys$output. Try

fprintf (stderr, "hello world\n");
Joseph Huber_1
Honored Contributor

Re: how to print to screen when com-procedure is run with /output ?

or
use TEE output to 2 streams, sys$output and sys$command (TT:) ?

$ help pipe examples
...
5.$ ! TEE.COM - command procedure to display/log data flowing through
$ ! a pipeline
$ ! Usage: @TEE log-file
...

You could use it like this:

$ pipe @abc | @tee abc.log
http://www.mpp.mpg.de/~huber
John Gillings
Honored Contributor

Re: how to print to screen when com-procedure is run with /output ?

Scotty,
If you want the same output to screen and log file use:

$ SUBMIT/LOG=work.log work

then:

$ TYPE/TAIL/CONTINUOUS WORK.LOG

If you want different output, then you'll need two channels. Use SYS$OUTPUT for your log and SYS$ERROR for progress:

$ c=0
$ loop: c=c+1
$ WRITE SYS$OUTPUT "C=''c'"
$ IF c/20*20.EQS.c THEN WRITE SYS$ERROR "Processed ''c'"
$ WAIT 00:00:00.1
$ GOTO loop

A benefit of using SYS$ERROR is, in BATCH mode both SYS$OUTPUT and SYS$ERROR will go to the log file. SYS$COMMAND will work in interactive mode, but techhnically it's supposed to be an input channel, so in BATCH mode it will attempt to write back to the executing procedure, which will fail.

Example of batch log file sending output to SYS$ERROR:

...
C=15
C=16
C=17
C=18
C=19
C=20
Processed 20
C=21
C=22
C=23
C=24

and using SYS$COMMAND:

...
C=16
C=17
C=18
C=19
C=20
%RMS-F-FAC, record operation not permitted by specified file access (FAC)
GILLINGS_J job terminated at 17-NOV-2010 08:01:04.89
A crucible of informative mistakes
Scotty HD
Frequent Advisor

Re: how to print to screen when com-procedure is run with /output ?

thanks to all.

Scotty