lpremote 782 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. if [ ! -n "$REMOTE_PRINT_HOST" ] ; then
  3. echo "\$REMOTE_PRINT_HOST is not set." >&2
  4. exit 1
  5. fi
  6. if [ ! -n "$REMOTE_PRINT_PATH" ] ; then
  7. echo "\$REMOTE_PRINT_PATH is not set." >&2
  8. exit 1
  9. fi
  10. if [ $# -lt 1 ] ; then
  11. echo "$0 file-to-print lp-options*" >&2
  12. exit 1
  13. fi
  14. FILE=$1
  15. shift
  16. BASE_FILE_NAME=$(basename "${FILE}" | tr ' ()' '___')
  17. if [ ! -e "$FILE" ] ; then
  18. echo "$FILE does not exist." >&2
  19. exit 1
  20. fi
  21. scp "${FILE}" "${REMOTE_PRINT_HOST}:${REMOTE_PRINT_PATH}${BASE_FILE_NAME}"
  22. if [ $? -eq 0 ] ; then
  23. ssh "$REMOTE_PRINT_HOST" -t "lp $@ ${REMOTE_PRINT_PATH}${BASE_FILE_NAME}"
  24. else
  25. echo "File Transfer Failed." >&2
  26. exit 1
  27. fi
  28. if [ $? -eq 0 ] ; then
  29. ssh "${REMOTE_PRINT_HOST}" -t "rm ${REMOTE_PRINT_PATH}${BASE_FILE_NAME}"
  30. fi