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 foo@bar.com
else

        echo lp queue is empty | /usr/ucb/mail foo@bar.com

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 /)"
Eve Bum
  • 1
  • 2
  • 1
    Does this answer your question? [Why is my crontab not working, and how can I troubleshoot it?](https://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it) – Gerald Schneider May 23 '23 at 04:31
  • No that DID NOT answer the question – Eve Bum May 23 '23 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)` – Andrew Henle May 24 '23 at 20:10

0 Answers0