/* ** $VER: pktshovel.rexx 2.0 (28.2.98) Rolf Rotvel */ cfgfile = 'mail:pktshovel.cfg' /* ** End cfg. */ call addlib('rexxsupport.library', 0, -30, 0) arg system . if system = '' then do say 'You must supply a system!' exit end if ~open('cfg', cfgfile, 'r') then do say 'Can''t find config file "'cfgfile'"!' exit end cfgtxt = space(upper(readch('cfg', 65535)), 1) call close('cfg') found? = 0 do forever if cfgtxt = '' then leave parse var cfgtxt 'SYSTEM' checksystem '0a'x cfgtxt if strip(checksystem) = system then do found? = 1 leave end end if ~found? then do say 'System "'system'" not found!' exit end count = 0 doscom = '' do forever parse var cfgtxt line '0a'x cfgtxt if cfgtxt = '' then leave chkword = word(line, 1) select when chkword = 'SYSTEM' then leave when chkword = 'MOVE' then do parse var line . fromdir todir node . if exists(fromdir) & exists(todir) then do count = count + 1 flow.count.from = fromdir flow.count.to = todir flow.count.address = translate(node, '..', ':/') end else say 'Cfg error: "'fromdir'" or "'todir'" doesn''t exist!' end when chkword = 'DOSCOM' then doscom = subword(line, 2) otherwise nop end end flow.0 = count do i = 1 to flow.0 base = makepath(flow.i.from, flow.i.address) call copynetmail(base'.DUT', flow.i.to) call copynetmail(base'.HUT', flow.i.to) call copynetmail(base'.CUT', flow.i.to) call copynetmail(base'.OUT', flow.i.to) call flowfileextract(base'.FLO', flow.i.to) call flowfileextract(base'.HLO', flow.i.to) call flowfileextract(base'.CLO', flow.i.to) end if doscom ~= '' then address command doscom exit /* ** Extract files from flowfile and copy them */ FLOWFILEEXTRACT: procedure arg flowfile, flowdest if ~open('flow', flowfile, 'r') then return do forever flowline = readln('flow') if flowline = '' then leave act = left(flowline, 1) select when act = '#' then act = 'TRUNC' when act = '^' | act = '-' then act = 'DEL' otherwise act = 'NONE' end if act ~= 'NONE' then flowline = substr(flowline, 2) if exists(flowline) then do filename = getname(flowline) ext = upper(right(filename, 4)) chk1 = left(ext, 3) chk2 = right(ext, 1) if find('.MO .TU .WE .TH .FR .SA .SU', chk1) > 0 & datatype(chk2, 'w') then do flowto = maketo(flowdest, '.'upper(left(date('w'), 2))'0') end else flowto = makepath(flowdest, filename) if act = 'DEL' then do if ~rename(flowline, flowto) then do call copyfile(flowline, flowto) call delete(flowline) end end else call copyfile(flowline, flowto) if act = 'TRUNC' then do call open('tmp', flowline, 'w') call close('tmp') end end end call close('flow') call delete(flowfile) return /* ** Copy netmail files */ COPYNETMAIL: procedure arg from, to if exists(from) then do to = maketo(to, '.PKT') if ~rename(from, to) then do call copyfile(from, to) call delete(from) end end return /* ** Create datestamped pkt file */ MAKETO: procedure parse arg dir, ext days = date('i') do forever to = makepath(dir, d2x(days||time('s'), 8)||ext) if ~exists(to) then return to end /* ** copyfile(sourcefile, destfile) */ COPYFILE: procedure parse arg from, to . call open('s', from, 'r') call open('d', to, 'w') do (word(statef(from), 2) % 65535) + 1 call writech('d', readch('s', 65535)) end call close('d') call close('s') return /* ** Join and together */ MAKEPATH: procedure parse arg path, file if pos(right(path, 1), ':/') = 0 then return path'/'file return path||file /* ** Separate filename from path */ GETNAME: procedure parse arg path return strip(substr(path, max(pos(':', path), lastpos('/', path)) + 1))