Advertisement
Guest User

OpenThinClient.org v1.0 custom script for scanbuttond

a guest
Aug 12th, 2011
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.39 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. LOCKFILE="/tmp/scan.lock"
  4.  
  5. TMPFILE="scans/$(hostname)_$(date +%Y-%m-%d_%H-%M-%S)"
  6.  
  7. SSH_CMD="ssh -i /etc/ssh/ssh_host_rsa_key scan@linux"
  8. SSH_CMD_BG="ssh -n -i /etc/ssh/ssh_host_rsa_key scan@linux"
  9.  
  10.  
  11. case $1 in
  12.         1)      SCAN_PARAM="--mode Color --resolution 200"; CONVERT_PARAM="-quality 80" ;;
  13.         2)      SCAN_PARAM="--mode Gray  --resolution 200"; CONVERT_PARAM="-quality 80 -colorspace Gray"        ;;
  14.         3)      SCAN_PARAM="--mode Color --resolution 400"; CONVERT_PARAM="-quality 70" ;;
  15.         4)      SCAN_PARAM="--mode Gray  --resolution 400"; CONVERT_PARAM="-quality 70 -colorspace Gray"        ;;
  16. esac
  17.  
  18.  
  19. case $1 in
  20.         1|2|3|4)
  21.                 if [ -f $LOCKFILE ]; then
  22.                         echo "Error: Another scanning operation is currently in progress"
  23.                         exit
  24.                 else
  25.                         echo "button $1 has been pressed on $2"
  26.  
  27.                         touch $LOCKFILE
  28.                         scanimage  $SCAN_PARAM  --format tiff | $SSH_CMD 'cat > '"$TMPFILE"".tiff"
  29.                         rm -f $LOCKFILE
  30.  
  31.                         $SSH_CMD_BG convert $CONVERT_PARAM "$TMPFILE"".tiff"  "$TMPFILE"".jpg"
  32.                         $SSH_CMD_BG convert $CONVERT_PARAM "$TMPFILE"".jpg"   "$TMPFILE"".pdf"
  33.                         $SSH_CMD_BG rm "$TMPFILE"".tiff"
  34.                 fi
  35.                 ;;
  36. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement