#!/bin/bash

. /usr/lib/lprfax/init

Script_Init $@

Erun $ABORT $SPLIT

LAST=$(ls -1 *.g3 | tail -1l)

BC=$(dd if=$LAST bs=1 count=6 2>/dev/null)

if [ "$BC" = "banner" ] ; then
    Erun $ABORT rm $LAST
    LAST=$(ls -1 *.g3 | tail -1l)
    NPAGES="$LAST $(ls -1 *.g3 |grep -v $LAST)"
else
    NPAGES="$(ls -1 *.g3)"
fi
PAGES=$(ls -1 *.g3 | wc -w)


ID=$(Get_Faxid $(echo $PRINTER | cut -f1 -d_))
Lookup_Names $NUMBER

Test_Number

Fax_Headers $NPAGES

Erun $ABORT $JOIN $NPAGES

exit 0

