srxses (Sat Oct 25 2014 01:31:01)

srxses

This program is used to grab files from Prestige/DewarView/Sypress editorial
systems.

It polls the input queue for files to send. When it finds a entry, it grabs the
file from Database and sends it according to the destination specified.

Only one database can be scavenged in this way but if you have split databases,
there can be several copies of the program all pointing to different
databases/banks determined by their own (different) parameter file.

Optionally the queue can be a printer queue. Note that this in a different
format to the normal text files, so pls take care. Use the '-p' input switch to
specify. This will grab the file and send it to a Fip destination specified in
the 'destprt:' parameter in the parameter file ('sesprt' by default). This
destination should be added to tables/sys/USERS. It can then be processed by
ippsc and/or ipprint to format and send to the printer.
In this case all routing, delay and limit are ignored.

Optionally the program can be used to scan a delay field in the database for
files that need to be sent out at a specified time and date. The '-x' input
switch is used to specify which 'dirstamp' field to track.

Normal running would be to have 2 or 3 copies of this program, one for general
text out, one for printing and an optional third for checking a delay field.

A parameter file for the data is held in tables/xses and defaults to XSES for
Dewar and XPRESTIGE for Prestige.

The Translation parameter file has the syntax :
note for most parameters - passwords, table and column names - case is
sometimes important so keep uppercase upper
	; comment line

Required keywords :
	dbname:(name of database)
		dbname:MimDewar
	dbdatabase:(name of database)
		dbdatabase:GNW
	Use this ONLY for Sybase or MSQL where we need to chg database after logging
on
	dbuser: (User logon)
		dbuser:DEWAR
	dbpwd: (user password)
		dbpwd:dribbleOG

	dbtbl: (table name where data resides)
		dbtbl:EDMASTER		default is EDMASTER for Dewar and story for Prestige
	fiphdr:
		fiphdr:(2 letter FipHdr code) (subparameters)
		fiphdr:SN	field:DOS_NAME	size:11	case:lower
		fiphdr:DF	data:DATABASE
		SubParameters can be :
			either	field:(SES Column name)
			or	data:(fixed string or variable data in FipSeq)
				size:(number)		- maximum length of field on output
				case:(lower|upper)	- force case of output data
				filename:		- flag this is the filename for magic DOT 
		Always specify a size for Mimer.7.1 - defaults is 50
		Certain FipHdr fields have special meaning and so should not be used.
		Generally please do not use fields begining S* or D* or X* and be careful
		and check the OUTPUT program which fields it uses before deciding.
		We advise fields starting Q* (which is ALWAYS a User definable) or N*
		Fip Fields which need to be filled in are (mandatory are marked with a *) :
		**	SN - actual filename				defaults to DOS_NAME
		**	SC - source chrset for XCHG			defaults to ASCII
		**	SU - source or Agency or Publication name	defaults to SES
			SA - Source subaddress such as Logon		default - ignored
		**	DU - destination as in the sys/USERS file	default: see below
			DA - Destination subaddress such as Logon	default - ignored
				This is required when sending to POST for Syndication or MailBox etc
			DE - Delay until (must be a date field)		default - ignored
			DL - Delay ignored AFTER (must be a date field)	default - ignored
			DF - Format for the output program		defaults to XSES
				As used by ipedsys, ipout, ipgtwy, ip2ses etc
			DB - Broadcast formatfile for ipbdcast		default: ignored
			PR - Story Priority				defaults to 3

Optional keywords :
	filename: New filename for output file in FipSeq
	outfmt:	Name for the output format field, DF		default: XSES
	chrset: Name of the SC or Source chrset for xchgs	default: ASCII
	doneq:	Done queue for original files once sent - or 'delete' to zap
		If this does NOT start with a '/', it is assumed under the DATA PATH
			(see -d Input switch, which defaults to spool/ses) 
			default doneq: done
	errorq:	Error queue for original files that CANNOT be sent
		If this does NOT start with a '/', it is assumed under the DATA PATH
			(see -d Input switch, which defaults to spool/ses) 
			default errorq: error
	defdest: Default Destination for files if nothing is found in the
		'Routing' field - the Fip DU field as per sys/USERS
		The default default is 'xses'
	force: Force the Destination to ALWAYS go to this destination (DU)
	destprt: Default Destination for printer files.	default: sesprt

	nohdr:	Do NOT add a Fip style header on the output file. def: add hdr
	routefile: name of routing file in tables/xses		default: none
	before: FipSeq string to be added BEFORE any data	default: none
	after:  FipSeq string to be added AFTER  any data	default: none
	newDU:  Use this 2 letter FipHdr field as the		default FipHdr field DU
		destination field for routing. This should be either
		an entry in the tables/sys/USERS file or an entry
		in the 'routefile' as described above and below.
	chkexists: Full Path/file or queuename
	chktimeout: Timeout for the 'chkexists' in seconds
		CHKEXISTS is a complete pathname of either a standing file or a queue. This
is used to check that NFS drives are actually mounted BEFORE writing new files.
The program checks for (default) 10 secs before aborting that file and
continuing on with the next. Change the timeout period with 'chktimeout:'
NOTE THAT PROCESSING BLOCKS FOR THIS FILE AND WILL BE RETRIED AT LEAST ONCE A
MINUTE.
		eg : chkexists:/data1/nfs/helios/.Desktop
		CHKTIMEOUT is the timeout for chkexists. Default is 10 seconds. This can be
'0' for never timeout or any number.
	missing-text: Text (in FipSeq) to be inserted when the text file is missing
		default:none
		missing-text:n ** Please contact Systems on x3300 - Missing Text **n
		trace-file: (TraceFile in FipSeq)					   default: none
				Stuff all Sql used and the results into this Trace file.
				The folder MUST exist beforehand.
				eg	  trace-file:/fip/log/sql/NEWS_EXTRACT.$d
For Dewar,
	if using the -F to poll a second table and that table is
	NOT called 'fip', change with 'dewar-poll-table'
	eg	dewar-poll-table:pollme

For Prestige (not Prestige Library Extract)
	poll-queue:
		database queue-group to poll		default:output-wire
		poll-queue:toap-wire
	done-queue:
		database done queue-group for files output in the poll
		done-queue:done-wire			default:sent-wire
	newEI	
		the FipHdr field containing the		default:EI
		'story_id'. Note that 'story_id' MUST be extracted.
		eg
			newEI:NI
			fiphdr:NI	field:story_id
	log-line:
		log message in FipSeq.			default: EI SN -> DU

  For Prestige Library Extract
	oracle-date-format:
		Format of the date in 'to_date' style	default:dd-mon-yyyy
	allow-no-edition:
		This allows requests for extracts specifying only the Pub and PubDate.
	get-all-story-ids:
		Replacement sql to be used to select the story-ids for this extract.
		See below for the default and fuller description.
	get-each-story-id:
		Replacement sql to be used to select the data for each story-id
		extracted from the "get-all-story-ads"
		See below for the default and fuller description.


Default output format field (DF) is XSES
Default chrset field (SC) is ASCII
Default send queue is spool/2go.

A routing file can optionally be specified in tables/xses and has the format :
;
;	Routing table for New Edito Sys
;
tst	yukodests hehe+leplep
where the searched-for string is 'tst' and valid destinations cover the rest of
the line. These destinations should be in the tables/sys/USERS file.

If no default destination is specified (defdest:) and there is nothing in the
DU 'Routing' field, or DU has NOT been specified, it will be sent to
destination 'xses' which should be in the USERS file.

Where sections of FipHdr fields are required or changes to the output style,
use keywords : fixed, partial, combie, optional, repeat, newdate and/or style.
(see The SysAdmin manual for more information).
 
	They are normally specified :
		fixed:QZ	1234543
		partial:QT	ST,3,2,U,<,>
		combie:QY	ep|na,(0000000)a 
		option:QE	ep,11,7,s
		repeat:QK	XK,-,3  
	or	repeat:QP	PK,,4,#X
		style:QS	XN,%.03d
		repeat:Q7	XC	spo=lov
		newdate:QD	hours+3	"ZYZTZD"

Input Parameters are all optional :
	-n : name of service			default: XSES
	-d : path to the data files
			default: spool/ses for Dewar
			default: /prestige/share/story for Prestige
		If this does NOT start with a '/', it is assumed under spool.
	-J : Drive for data files (NT only)	default: c for c:
		This is a single letter
	-i : Input queue to scroll		default: send
		For Dewar	 - If this does NOT start with a '/', it is assumed under the DATA
PATH (-d)
		For Prestige	- If this does NOT start with a '/', it is assumed under 'spool'
		For Prestige this is ONLY used for the Library Extract -E

	-D : Dewar delay dirstamp queue and name	default: none
		If this does NOT start with a '/', it is assumed under the DATA PATH (-d)
		eg -D dirstamp/delay
		
	-l : do NOT log files in		default: normal log
	-L : log eveything			default: normal log
	-o : output queue			default: spool/2go	
		If this does NOT start with a '/', it is assumed under spool.
	-p : Dewar print request queue 		default: none
		This expects the files to be in SES printer request format.
		If this does NOT start with a '/', it is assumed under the DATA PATH (-d).
	-r : routing file in tables/xses	default: none
	-s : logon and off for each file.
		default: logon on the first file until logged off by the server
	-u : owner if not that of the logon	default: logon at start
	-w : Dir Stamp path name		default: dirstamp
		If this does NOT start with a '/', it is assumed under the DATA PATH (-d).
		To stop the DirStamp :  -w""
	-X : Time between reconnects when Database is down.	def: 10 secs.
	-Y : Strip leading and trailing spaces from Author/Filename.	default: no
		use this is the two fields are specified as fixed size.
	-z : parameter file in tables/xses	default: same name as -n for name
	-P : This is a Prestige system			default:DewarView
	-E : This is a Prestige system Library Extract	default:DewarView
	-F : This is a Dewar Polling table		default:DewarView
	-S : display Sql strings and results		default: do not
		Use this to debug errant connections.
	-y : use sffsleep to pause (fudges Oracle ignoring signals) default: no
	-v : print version number and exit

**Examples for SYSTEM file :
; Normal extractions
xses	local	ipxsesora -d/ses/network/txtfiles
; delay tracking
delay	local	ipxsesora -d/ses/network/txtfiles -D/ses/network/dirstamp/delay
; Printing
sesprt	local	ipxsesora -d/ses/network/txtfiles -p -i/ses/network/print -zsesprt

; Prestige Library Extract
prelib	local	ipxdb	-E -JF -d/ -o 2qtags -z xprelib
qtags	local	ipqtags -qlibdone
; Prestige Normal Export
xpres	local	ipxdb	-P -JF -d/

If using the Prestige flag '-P' or Library Extract '-E', note that :
	- FipHdr field EI MUST hold the unique 'story_id' to use for each story
		for the Library Extract it is automatic but for ordinary extracts, you
		MUST specify the 'fiphdr'.
	- No dirstamp and queue
	- Default data queue is /prestige/share/story (usually on F:)

For installation on NT please make sure that the mapped drive is available for
the logon used to start the Service (ipsvce or ipntsvce)
Look in ControlPanel/Services/Fip/Startup and make automatic and also changed
the 'log On as' to the ciorrect logon and password.
You MUST start and restart the service for this to take effect.

  -------------------------
For Prestige Library Extract, there are two steps :
	1. select all the story-ids relevant
	2. Loop around these story-ads, extracting relevant data.

To change the former, use get-all-story-ids' keyword, using FipSeq for
variables.
The default select string is :
	select distinct story.story_id from story, doc, pubinfo
	where story.doc_id = doc.doc_id
	and doc.pubinfo_id = pubinfo.pubinfo_id
	and pubinfo.pub = "EU"
(next line is Oracle only)
	and trunc(doc.pubdate) = trunc(to_date ('ED', 'dd-mmm-yyyy'))
(next line is all BUT Oracle)
	and doc.pubdate = "ED"
(If an Edition has been stated)
	and pubinfo.edition = "EE"
(if a Zone has been stated)
	and pubinfo.zone = "EZ"
(if a Section has been stated)
	and pubinfo.section = "ES"

	Note that for Oracle double quotes " should be replaced by single quotes '.
	FipHdr fields are :
		Publication	EU
		Edition		EE
		Date		ED	(**must be in SqlSvr format - 27-mar-1998)
		Zone		EZ	(optional)
		Section		ES	(optional)

If 'doc' and 'pubinfo' tables are NOT used, you may also want to change the
joins for the select statement grabbing the data for EACH story-id using the
'get-each-story-id'.
Note ONLY the FROM/joins are required as the first part of the select is formed
dynamically from your parameter file.
The default is  (note leading space)
	FROM story,doc,pubinfo WHERE story.story_id = "EI"
	and story.doc_id = doc.doc_id
	and doc.pubinfo_id = pubinfo.pubinfo_id
where EI is the temporary FipHdr field holding a single story-id.
NOTE - You MUST specify the whole string one one line.

Version Control
;008i	25apr00 added -F for polling the 'fip' table in Dewar
	;a 25may00 added order-by for dewar poll
	;b 26feb01 PAR reports zombies - none found but WAIT added in case
	;c 01aug02 added -y to use sffsleep for oracle fudge
	;d/e 13dec02 added -S for display SQL (only chdrive for data dir/fopen/stat)
	;f-g 29apr03 added newEI properly for Prestige Library
	;h-i 02sep06 odbc version
;007	20mar00 added mysql and mod for DCT
;006b	18feb99 added Oracle Dates plus OraDateFmt plus allow-no-edition
	MaxFiles per PresLibExtract (MaxRows) was 100 is now 5000.
	;a 06jul99 Prestige Extract - added newEI and log-line
	;b 20sep99 did WINNT drives better

(copyright) 2014 and previous years FingerPost Ltd.