0
#!/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

Works fine as a shell script; cron cannot cat $stuff

edit2: changed these 2, same result

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 /)"
3
  • 1
    Does this answer your question? Why is my crontab not working, and how can I troubleshoot it? May 23, 2023 at 4:31
  • No that DID NOT answer the question
    – Eve Bum
    May 23, 2023 at 14:18
  • Works fine as a shell script Huh? On my Solaris system, it never gets past stuff=\\`ls -1 /var/spool/lp/requests/localhost/ | /usr/bin/head -1\\` - it just emits -1: not found with those escaped backticks in place. And Solaris sh does not support ( ) as a replacement for backtick evaluation, so stuff="(ls -1 /var/spool/lp/requests/localhost/ | /usr/bin/head -1)" merely sets the stuff envval to the literal string (ls -1 /var/spool/lp/requests/localhost/ | /usr/bin/head -1) May 24, 2023 at 20:10

0

You must log in to answer this question.

Browse other questions tagged .