#!/bin/sh
#grab oldest file from queue
stuff=\`ls -1 /var/spool/lp/requests/localhost/ | /usr/bin/head -1\`
#pull printer name from lp requests (first line in file)
puff=\`cat $stuff | /usr/bin/head -1 | sed -e 's/-.*//' -e 's/$/ is having issues printing from /'\`
if [ "$(ls -A /var/spool/lp/requests/localhost/)" ]
then
echo $puff | /usr/ucb/mail [email protected]
else
echo lp queue is empty | /usr/ucb/mail [email protected]
fi
作为 shell 脚本运行良好;cron 无法 cat $stuff
编辑2:更改了这两个,结果相同
stuff="(ls -1 /var/spool/lp/requests/localhost/ | /usr/bin/head -1)"
puff="$(cat $stuff | /usr/bin/head -1 | sed -e 's/-.*//' -e 's/$/ is having issues printing from /)"