checkuserpasswdPDF.sh
:
#!/bin/sh
GS=~/gs/bin/gs
output=`$GS -dBATCH -sNODISPLAY "$1" 2>&1`
gsexit=$?
if [ "$gsexit" == "0" ]; then
echo "Not user-password protected"
exit 0;
else
found=`echo "$output" |grep -o "This file requires a password"`
if [ -z "$found" ]; then
echo "Failed to invoke gs"
exit $gsexit
else
echo "Protected"
exit 0;
fi
fi
Checks for user-password protected PDFs: checkuserpasswdPDF.sh test.pdf
.
GS disregards owner-passwords (see this).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…