home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
back2roots/padua
/
padua.7z
/
padua
/
uucp
/
bsmtp.lzh
/
bsmtp
/
batchthem.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1991-12-06
|
5KB
|
181 lines
/* batch mails for certain host */
/* Version 1.02 Friday 06-Dec-91 16:11:25 */
/* by Georg Sassen (georg@bluemoon.GUN.de */
/* open rexxsupport.library */
if ~show('L','rexxsupport.library') then do
if ~addlib('rexxsupport.library',0,-30,0) then do
say 'Could not open rexxsupport.library'
exit 20
end
end
/* create names for a temporary files */
tofile = 't:rx1'||pragma('Id')
tmptmp = 't:rx2'||pragma('Id')
/* constants */
rcmax = 0
TRUE = 1
FALSE = 0
hostname = FindConfig('NodeName')||FindConfig('DomainName')
ccmd = 'freeze' /* or compress... */
rcmd = 'rfsmtp' /* or rcsmtp for compress */
if ~exists('uuspool:outbak') then
address command 'makedir uuspool:outbak' /* make directory for backup copies if
it doesn't exist */
/* get hostnames from commandline */
parse arg systems
sys.0 = words(systems)
if sys.0 ~= 0 then do
do i = 1 to sys.0
sys.i = trim(word(systems,i))
end
end
/* get the command files for each host from uuspool: */
do i= 1 to sys.0
mydir = showdir('uuspool:')
dir.i.0 = words(mydir)
if dir.i.0 ~= 0 then do
ind = 0
do j = 1 to dir.i.0
temp=trim(word(mydir,j))
if index(temp,'C.' || strip(left(sys.i,7))) ~= 0 then do
ind = ind + 1
dir.i.ind = temp
end
dir.i.0 = ind
end
end
end
/* Now we have a listing of the 'C.hostname#?' command files
in uuspool: in dir.i.j */
do i = 1 to sys.0
do j = 1 to dir.i.0
say dir.i.j
end
say 'Hooray...'
end
/* Which of them are for mail (and not for news) ?
* We assume the following format for the C.* files:
* S D.egosoftB0d7i D.bluemooB0d7k georg - D.egosoftB0d7i 0666
* ^ local ^ remote filename of data file (e.g. news/mail)
* S D.egosoftX0d7i X.bluemooX0d7j georg - D.egosoftX0d7i 0666
* ^ local ^ remote filename of command file (i.e. the one with rmail
* ^ S=send, R=receive (ignored by now...) foo!bar)
* Now we just look into the command files if there is an rmail line, which
* means we have to process it. */
do i = 1 to sys.0
ret = open('out',tofile,'W')
writeln('out','HELO '||hostname)
do j = 1 to dir.i.0
ret = open('myfile','uuspool:'||dir.i.j)
if ret ~= 1 then do
say 'Panic - where is my file' dir.i.j '?'
exit 20
end
temp = readln('myfile')
parse var temp rubbish datafile rubbish
temp = readln('myfile')
parse var temp rubbish commandfile rubbish
close('myfile')
/* open the command file: */
ret = open('myfile','uuspool:'||commandfile)
if ret ~= 1 then do
say 'Oerks - where is uuspool:'||commandfile '?'
exit 20
end
do while (~eof('myfile'))
temp = readln('myfile')
if left(temp,1) = 'C' then
break
end
close('myfile')
parse var temp rubbish command address /* C rmail bluemooon!georg */
if command = 'rmail' then do
call doit datafile,address
address command 'rename "uuspool:('||commandfile||'|'datafile||'|'||dir.i.j||')" uuspool:outbak'
end
end
writeln('out','QUIT')
close('out')
address command ccmd' <'||tofile||' >'||tmptmp
if RC > rcmax then rcmax=RC
address command 'uux '||tmptmp||' '||sys.i||'!'||rcmd
if RC > rcmax then rcmax=RC
end
address command 'delete '||tofile
address command 'delete '||tmptmp
exit rcmax
doit: procedure
parse arg datafile,address
say 'Processing mail from file' datafile 'to' strip(address)
ret = open('myfile','uuspool:'||datafile)
if ret ~= 1 then do
say 'Where is uuspool:'||datafile '?'
exit 20
end
hdrline = readln('myfile')
parse var hdrline 'From 'user date' remote from ' fromhost
say "Fromuser:" user "Date:" date "Fromhost:" fromhost
from = fromhost||'!'||user
writeln('out','MAIL FROM:<'||from||'>')
do i = 1 to words(address)
writeln('out','RCPT TO:<'||trim(word(address,i))||'>')
end
writeln('out','DATA')
do while ~eof('myfile')
line = readln('myfile')
if line='.' then line='..'
writeln('out',line)
end
close('myfile')
writeln('out','.')
return
/* Findconfig function similar to the C-thing in uucp.lib */
/* Note: no TAB's in Configfile allowed... */
FindConfig:
arg configname
if exists('s:UUConfig') then
filename = 's:UUConfig'
else
filename = 'UULib:Config'
ret=open('configfile',filename,'R')
if ret = FALSE then do
say 'Can''t open '||filename
exit 20
end
do while ~eof('configfile')
string = readln('configfile')
if upper(word(string,1))=upper(configname) then do
close('configfile')
return delword(string,1,1)
end
end
close('configfile')
return 'NotFound'