Re: Process Scheduler


[ Follow Ups ] [ Post Followup ] [ Message Board ]

Posted by [IP Address: 132.170.238.171] 'Bradley Smith' on June 19, 2001 at 11:41:17 EST:

In Reply to: Process Scheduler posted by [IP Address: 132.170.238.171] 'Sanjeev Puri' on May 24, 2001 at 13:01:34 EST:

I wrote an SQR, which loads a logfile into a table. Then with a panel you can view the log file. I have included the short sqr program:
=====cut here====
#include 'setenv.sqc'
#include 'setup31.sqc'


begin-program


do Initialize

do Terminate
end-program

begin-procedure Initialize ! Get Source Database Information

do Init-DateTime
do Get-Current-DateTime
do Define-Prcs-Vars
do Get-Run-Control-Parms

let $HOME_DIR = '/app/psoft/'
let $TEMP_FILE = 'cfviewlg.' || $prcs_oprid
let $MAX_LINES = '5000'

begin-select
prcsinstance &rid

from PS_CF_VIEW_LOG_RUN
where RUN_CNTL_ID = $prcs_run_cntl_id

end-select


begin-select
DBNAME &dbname1
from PS.PSDBOWNER
end-select

let $dbname = &dbname1
let $runid = rtrim ( ltrim (edit (&rid, '9999999'), ' ' ), ' ')
let $WORK_DIR = $HOME_DIR || '*/appserv/prcs/' || $dbname || '/logs/*' || $runid || '.log'
!let $WORK_CMD = 'head -10000 ' || $WORK_DIR || ' > ' || $TEMP_FILE || ' 2>&1 '
let $WORK_CMD = '(if [ -r ' || $WORK_DIR || ' -a `cat ' ||
$WORK_DIR || ' |wc -l` -gt ' || $MAX_LINES ||
' ] ; then ( head -' || $MAX_LINES || ' ' || $WORK_DIR ||
' ; echo "**********"; echo "****** LAST 50 LINES ******"; ' ||
'echo "**********" ; tail -50 ' || $WORK_DIR ||
' ); else cat ' || $WORK_DIR || '; fi ) > ' ||
$TEMP_FILE || ' 2>&1 '


call system using $WORK_CMD #unix_status

show $WORK_CMD
show 'unix status is ' noline
show #unix_status

begin-sql
delete from PS_CF_VIEW_LOG where oprid = $prcs_oprid
end-sql

commit


let #rec_num = 1

open $TEMP_FILE as 1 for-reading record=254

while 1 !do the following
read 1 into $inline:254
!show #rec_num
!show $inline
if #end-file
break
end-if
if $inline = ''
let $inline = ' '
end-if
begin-sql
insert into ps_cf_view_log(oprid, seq_num, descr254)
values ( $prcs_oprid, #rec_num, $inline)
end-sql
let #rec_num = #rec_num + 1
end-while

commit

show 'Lines Inserted: ' noline
show #rec_num


end-procedure


begin-procedure Terminate
if #prcs_process_instance > 0
do Update-Prcs-Run-Status
end-if

end-procedure
#include 'reset.sqc'
#include 'datetime.sqc'
#include 'curdttim.sqc'
#include 'prcsapi.sqc'
#include 'prcsdef.sqc'


=====end of pgm==

: How to check the logs of process sheduler through GUI.




Follow Ups:



Post a Followup


Name:
E-Mail:
Subject:

Message:


[ Follow Ups ] [ Post Followup ] [ Message Board ]