Want more features on Pastebin? Sign Up, it's FREE!
Guest

OpenThinClient.org v1.0 custom script for scanbuttond

By: a guest on Aug 12th, 2011  |  syntax: Bash  |  size: 1.39 KB  |  views: 90  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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
clone this paste RAW Paste Data