Use gs to check page count before sending

callerid
Gandalf 2021-04-19 12:52:47 +02:00
parent 93e37156d8
commit e05bfac110
1 changed files with 10 additions and 0 deletions

10
fax.sh
View File

@ -63,6 +63,16 @@ then
echo "File too big. Cannot be more than 10MB."
exit 2
fi
if hash gs 2>/dev/null
then
if [ $(gs -q -dNODISPLAY -c "(fax.pdf) (r) file runpdfbegin pdfpagecount = quit" 2>&1) -gt 30 ]
then
echo "Sipgate won't send your file, because it has more than 30 pages"
exit 2
fi
else
echo "ghostscript not installed, cannot check for page numbers. Sipgate accepts up to 30 pages."
fi
#Needs to be base64 encoded:
CONTENT=$(base64 "$FILE" -w 0)
if [ -z "$CONTENT" ];