From e05bfac110c50e81fb46b1832b3392a84c7fe1a6 Mon Sep 17 00:00:00 2001 From: Gandalf Date: Mon, 19 Apr 2021 12:52:47 +0200 Subject: [PATCH] Use gs to check page count before sending --- fax.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fax.sh b/fax.sh index 1ff997e..4c92a3e 100755 --- a/fax.sh +++ b/fax.sh @@ -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" ];