#!/usr/local/bin/rexx
kko=4000
PARSE ARG KoTo
"cd /var/spool/mail"
IF KoTo="" THEN KoTo='institut'

SAY 'Pokusavam da sredim mailbox za korisnika "'KoTo'"'  
SAY "Kopiram mailbox ..."
"/bin/cp "KoTo KoTo"-old" 
SAY "---> Mailbox kopiran!"
SAY "Citam mailbox ..."
"/bin/cat "KoTo"-old >FIFO"
nx=QUEUED() 
xx=trunc(nx/kko)
SAY "---> Mailbox procitan ("nx" linija == "xx" delova)!"

Ukupno=0
DO i=1 TO xx
   Say "Radim deo "i" od "xx" ..."
   "/bin/rm "KoTo"-"i" >& /dev/null"
   DO j=1 TO kko
      PARSE PULL linija
      IF j=kko THEN
         IF LEFT(linija, 5)="From " THEN
            "echo "linija" >LIFO"
         ELSE DO
            Call LineOut KoTo"-"i, linija
            j=j-1
            END
      ELSE
         Call LineOut KoTo"-"i, linija
 
      ukupno=ukupno+1
      IF ukupno==nx THEN Exit
   END
   IF ukupno==nx THEN Exit
   "chown "KoTo".mail "KoTo"-"i
END

SAY "Regularan kraj ..."
Exit

