check_queue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #! /bin/sh
  2. #===============================================================
  3. # Print Queue Checker
  4. #
  5. # The print queue checker simply looks for an occurance of a
  6. # DOWN queue. A note of warning, if you use remote queues in
  7. # AIX to redirect print jobs from the AIX queue to an NT print
  8. # server that print through DLC rather than IP, it will be very
  9. # s - l - o - w. But it will work.
  10. #
  11. # Author: TheRocker
  12. # Email: therocker@pawprints.2y.net
  13. #===============================================================
  14. TMPFILE=/tmp/qtmp.hndl
  15. TMPTOO=/tmp/qtwo.hndl
  16. #=======================================================================
  17. #
  18. # This script will also work on AIX 4.2.1 BUT you have to change
  19. # the following line. AIX 4.2.1 does not support the -W option
  20. # with lpstat. For AIX 4.2.1 just remove the -W option and it should
  21. # work just fine.
  22. #
  23. #=======================================================================
  24. `rsh $1 -l root lpstat -W | grep -e "DOWN" | tr -s ' ' | cut -d' ' -f1,3 > /tmp/qtmp.hndl 2> /tmp/q_err`
  25. if [ -s $TMPFILE ]
  26. then
  27. #=======================================================
  28. #
  29. # If you've seen the other AIX scripts I wrote you may
  30. # notice that I use this bit of code a lot. Well it
  31. # works and appears to be all purpose.
  32. #
  33. #=======================================================
  34. LINES=`wc -l /tmp/qtmp.hndl | cut -c8`
  35. LINESCTL=`wc -l /tmp/qtmp.hndl | cut -c8`
  36. echo "Print Queue DOWN --> \c"
  37. while [ $LINESCTL != 0 ]
  38. do
  39. cat $TMPFILE | tail -$LINESCTL > $TMPTOO
  40. cat $TMPTOO > $TMPFILE
  41. LINESCTL=$(( $LINESCTL -1 ))
  42. LINES=$(( $LINES -1 ))
  43. DATA=`head -1 /tmp/qtmp.hndl`
  44. echo "( $DATA ) \c"
  45. done
  46. echo "\n"
  47. rm -f $TMPFILE
  48. rm -f $TMPTOO
  49. exit 2
  50. fi
  51. echo "Print Queues Running... OK"
  52. exit 0