usr/share/hplip/info.patched0000644000000000000000000001725511664670360015113 0ustar rootroot#!/usr/bin/env python NOROOT=fill_here linux account that will run ocropus and store files. ##################### End of config. ############################## # should be installed on computer USB-linked to HP LaserJet 3020. # BUGS: not documented, not in any ebuild # patches, comments to dREPLACEeLETTEReEjBYeLETTEReA A T gmail D O T com or https://bugs.gentoo.org/show_bug.cgi?id=185810' >&2 # /usr/share/hplip/info.patched # -*- coding: utf-8 -*- # # (c) Copyright 2003-2007 Hewlett-Packard Development Company, L.P. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Author: Don Welch # __version__ = '3.4' __title__ = 'Device Information Utility' __doc__ = "Query a printer for both static model information and dynamic status." # Std Lib import sys, getopt, time # Local from base.g import * from base import device, status, utils from prnt import cups USAGE = [(__doc__, "", "name", True), ("Usage: hp-info [PRINTER|DEVICE-URI] [OPTIONS]", "", "summary", True), utils.USAGE_ARGS, utils.USAGE_DEVICE, utils.USAGE_PRINTER, utils.USAGE_SPACE, utils.USAGE_OPTIONS, ("Device ID mode:", "-i or --id (prints device ID only and exits)", "option", False), utils.USAGE_BUS1, utils.USAGE_BUS2, utils.USAGE_LOGGING1, utils.USAGE_LOGGING2, utils.USAGE_LOGGING3, utils.USAGE_HELP, utils.USAGE_SPACE, utils.USAGE_NOTES, utils.USAGE_STD_NOTES1, utils.USAGE_STD_NOTES2, utils.USAGE_SEEALSO, ("hp-toolbox", "", "seealso", False), ] def usage(typ='text'): if typ == 'text': utils.log_title(__title__, __version__) utils.format_text(USAGE, typ, __title__, 'hp-info', __version__) sys.exit(0) log.set_module('hp-info') try: opts, args = getopt.getopt(sys.argv[1:], 'p:d:hl:b:ig', ['printer=', 'device=', 'help', 'help-rest', 'help-man', 'help-desc', 'logging=', 'id', 'bus=']) except getopt.GetoptError: usage() printer_name = None device_uri = None log_level = logger.DEFAULT_LOG_LEVEL bus = "cups,par,usb" devid_mode = False if os.getenv("HPLIP_DEBUG"): log.set_level('debug') for o, a in opts: if o in ('-h', '--help'): usage() elif o == '--help-rest': usage('rest') elif o == '--help-man': usage('man') elif o == '--help-desc': print __doc__, sys.exit(0) elif o in ('-p', '--printer'): if a.startswith('*'): printer_name = cups.getDefault() log.info("Using CUPS default printer: %s" % printer_name) log.debug(printer_name) else: printer_name = a elif o in ('-d', '--device'): device_uri = a elif o in ('-b', '--bus'): bus = a.lower().strip() if not device.validateBusList(bus): usage() elif o in ('-l', '--logging'): log_level = a.lower().strip() if not log.set_level(log_level): usage() elif o == '-g': log.set_level('debug') elif o in ('-i', '--id'): devid_mode = True if device_uri and printer_name: log.error("You may not specify both a printer (-p) and a device (-d).") usage() if not devid_mode: utils.log_title(__title__, __version__) if not device_uri and not printer_name: try: device_uri = device.getInteractiveDeviceURI(bus) if device_uri is None: sys.exit(1) except Error: log.error("Error occured during interactive mode. Exiting.") sys.exit(1) try: d = device.Device(device_uri, printer_name) except Error: log.error("Error opening device. Exiting.") sys.exit(1) if d.device_uri is None and printer_name: log.error("Printer '%s' not found." % printer_name) sys.exit(1) if d.device_uri is None and device_uri: log.error("Malformed/invalid device-uri: %s" % device_uri) sys.exit(1) if not devid_mode: log.info("") log.info(utils.bold(d.device_uri)) log.info("") user_cfg.last_used.device_uri = d.device_uri try: d.open() d.queryDevice() except Error, e: log.error("Error opening device (%s). Exiting." % e.msg) sys.exit(1) res="pas encore lu" nbetape=2 # fin quand on a lu un dieze sur l'ecran, et qu'il a disparu. while nbetape > 0: try: d.queryDevice() except Error, e: log.error( "Error querying device (%s). Exiting." % e.msg) try: d.close() except Error, e: log.error( "Error closing device (%s). Exiting anyway." % e.msg) sys.exit(1) res= str(d.dq["panel-line1"])+ str(d.dq["panel-line2"]) log.info( res ) noscan=1 try: f = open("/home/$NOROOT/scans/noscan") except: noscan=0 if noscan == 1: f.close() nbetape=0 if len(res) < 5: nbetape=0 else: if -1 == res.find("#"): if nbetape == 1: nbetape=0 else: if nbetape == 2: nbetape=1 try: d.close() except Error, e: log.error( "Error closing device (%s). Exiting anyway." % e.msg) # if not devid_mode: # formatter = utils.TextFormatter( # ( # {'width': 28, 'margin' : 2}, # {'width': 58, 'margin' : 2}, # ) # ) # # if devid_mode: # try: # print d.dq['deviceid'] # except KeyError: # log.error("Device ID not available.") # else: # dq_keys = d.dq.keys() # dq_keys.sort() # # log.info(utils.bold("Device Parameters (dynamic data):")) # log.info(utils.TextFormatter.bold(formatter.compose(("Parameter", "Value(s)")))) # log.info(formatter.compose(('-'*28, '-'*58))) # # for key in dq_keys: # log.info(formatter.compose((key, str(d.dq[key])))) # # log.info(utils.bold("\nModel Parameters (static data):")) # log.info(utils.TextFormatter.bold(formatter.compose(("Parameter", "Value(s)")))) # log.info(formatter.compose(('-'*28, '-'*58))) # # mq_keys = d.mq.keys() # mq_keys.sort() # # for key in mq_keys: # log.info(formatter.compose((key, str(d.mq[key])))) # # formatter = utils.TextFormatter( # ( # {'width': 20, 'margin' : 2}, # date/time # {'width': 5, 'margin' : 2}, # code # {'width': 40, 'margin' : 2}, # desc # {'width': 8, 'margin' : 2}, # user # {'width': 8, 'margin' : 2}, # job id # ) # ) # # # log.info(utils.bold("\nStatus History (most recent first):")) # log.info(utils.TextFormatter.bold(formatter.compose(("Date/Time", "Code", "Status Description", "User", "Job ID")))) # log.info(formatter.compose(('-'*20, '-'*5, '-'*40, '-'*8, '-'*8))) # # hq = d.queryHistory() # # for h in hq: # if h[9]: # j = str(h[9]) # else: # j = '' # log.info(formatter.compose((time.strftime("%x %H:%M:%S", h[:9]), str(h[11]), h[12], h[10], j))) # # log.info("") # # d.close() sys.exit(0) usr/local/sbin/scanautomatique0000644000000000000000000000435011664670360015553 0ustar rootroot#! /bin/sh NOROOT=fill_here linux account that will run and store files. ##################### End of config. ############################## # should be installed on computer USB-linked to HP LaserJet 3020. # BUGS: not documented, in /usr/local/sbin/scanautomatique rather that /etc/init.d/scanautomatique, not in any ebuild # screen -d -m su - $NOROOT -c 'env HOME=/home/$NOROOT bin/.scan.automatique' # patches, comments to dREPLACEeLETTEReEjBYeLETTEReA A T gmail D O T com or https://bugs.gentoo.org/show_bug.cgi?id=185810' >&2 timestamp=/home/$NOROOT/scans/timestamp.last.scanimage.check touch $timestamp # au bout de 30 minutes sans réponse, il y a bourrage. while sleep 1800 do for pid in `fuser /usr/bin/scanimage 2> /dev/null | sed 's: ::'` do test $timestamp -nt /proc/$pid/fd/0 && { kill $pid ; for signal in 11 9 ; do sleep 10 ; fuser /usr/bin/scanimage | grep $pid && kill -$signal $pid ; done ; } done touch $timestamp done & status=1 while test $status '!=' 13 do # { su - $NOROOT -c 'env HOME=/home/$NOROOT bin/.scan.automatique 2>&1' 2>&1 && status=2 || status=0 ; } | tee -a /home/$NOROOT/scans/scan.automatique.log { HOME=/home/$NOROOT /home/$NOROOT/bin/.scan.automatique 2>&1 ; status=$? ; } | tee -a /home/$NOROOT/scans/scan.automatique.log echo resultat retourne $status 2>&1 | tee -a /home/$NOROOT/scans/init.scan.log { date sleep 1 rmmod uhci_hcd ehci_hcd ohci_hcd sleep 1 modprobe uhci_hcd # la premiere fois, il ne trouve pas tel symbole ... modprobe uhci_hcd modprobe ehci_hcd # a mon avis c'est ohci_hcd le bon, on verra une autre fois. modprobe ohci_hcd sleep 1 #status=`/usr/share/hplip/info.py 2>&1 | { grep 'error: No devices found.' > /dev/null && { echo -n 1 ; } ; echo -n 3 ; } ; ping -c 1 thebes > /dev/null || { ping -c 1000 $ROUTER > /dev/null || echo 13 ; } ; }` #} | tee -a /home/$NOROOT/scans/init.scan.log status=`/usr/share/hplip/info.py 2>&1 | { grep 'error: No devices found.' > /dev/null && { echo -n 1 ; } ; echo -n 3 ; }` } | tee -a /home/$NOROOT/scans/init.scan.log done shutdown -r +60 "Le scanner est déconnecté, le mac va rebooter dans une heure. signe /usr/local/sbin/scanautomatique" # shutdown -r 1:00 "Le scanner ou la carte ethernet est déconnecté, le mac va rebooter. signe /usr/local/sbin/scanautomatique" home/NOROOT/bin/.scan.automatique0000644000000000000000000003774611664670360015610 0ustar rootroot#! /bin/sh NOROOT=fill_here linux account that will run ocropus and store files. AUTHOR=fill_here author of this file is anonymous. cible=fill_here this linux machine should host /usr/local/bin/.post.scan and correct /home/$NOROOT/.ssh/authorized_keys file. INSTITUTION=fill_here ##################### End of config. ############################## # should be installed on computer USB-linked to HP LaserJet 3020. # BUGS: not documented, file in /home/$NOROOT/bin instead of /usr/bin, not in any ebuild, $router not necessary # may be launched by /usr/local/sbin/scanautomatique or by screen -d -m su - $NOROOT -c 'env HOME=/home/$NOROOT bin/.scan.automatique' # patches, comments to dREPLACEeLETTEReEjBYeLETTEReA A T gmail D O T com or https://bugs.gentoo.org/show_bug.cgi?id=185810' >&2 cd /home/$NOROOT/scans # cat /root/.ssh/*.pub | ssh $NOROOT@$cible tee -a .ssh/authorized_keys echo 'Ce scanner HP LaserJet 3020 fait de la' echo echo ' ******************************************************************' echo ' ****** RECONNAISSANCE DE CARACTERES SUR FEUILLES IMPRIMEES. ******' echo ' ******************************************************************' echo echo 'Il vous enverra un fichier .pdf copier-collable par e-mail.' echo echo 'Pour cela :' echo '(a) Mettre vos feuilles dans le bac du haut face dessus, tête à gauche' echo ' (ou sur la vitre, tête à droite, calé vers vous).' echo '(b) Sur le clavier du scanner, tapez votre numéro de poste $INSTITUTION.' echo '(c) Si vous voulez changer les paramètres par défaut, tapez [*] suivi d un numéro' echo ' (en suivant les indications de la liste OPTIONS ci-dessous).' echo '(d) Sur le clavier du scanner, tapez [#].' echo '(e) Attendre cinq secondes, il ne se passe rien.' echo '(f) Sur le clavier du scanner, taper [Annuler].' echo '(g) Attendre dix secondes, puis le scanner va commencer à scanner' echo ' (ne pas prendre en compte ce qui est affiché sur l écran du scanner).' echo '(h) Quand le scanner affiche Pret, c est terminé et on peut scanner à nouveau.' echo echo 'Si vous êtes chanceux, d ici une dizaine de secondes, le scanner devrait' echo 'chauffer sa lampe puis scanner. Sinon, voir la section PROBLEMES tout en bas.' echo echo 'Merci de proteger la vitre des RAYURES, GRAISSES, SUCRES, PROTEINES, ...' echo echo ' ******************************************************************' echo ' **************************** OPTIONS *****************************' echo ' ******************************************************************' echo echo 'Si votre poste est 5069, et que votre document est en paysage (et non portrait),' echo 'ajoutez *7, ce qui donne :' echo echo '[5] [0] [6] [9] [*] [7] [#]' echo echo 'Avant le dièze (#), on donc peut mettre une option comme *7 (ci-dessus) pour' echo 'préciser que le document est horizontal. Voici ci-dessous la liste des options' echo 'possibles.' echo echo ' Les options essentielles sont *4 pour la couleur, *3 pour la résolution, *6' echo 'pour spécifier un nombre de pages, *2 pour le recto-verso.' echo echo ' On peut avoir plusieurs options mais en tapant lentement, par exemple' echo '5069*192*3600*4*21*24# pour ceux qui veulent des images jpg assez fidèles à' echo 'télécharger sur samba:\\'$cible'\' echo # ping -c 1 thebes || { ping -c 1000 $router || { echo carte ethernet en cause ; exit 2 ; } ; } #c etait eth1394 qui a trouve eth0 a la place de la carte ethernet. { ssh $NOROOT@$cible /usr/local/bin/.post.scan | grep -v 5188a10b | sed -e 's:a\([0-9]\):\*\1:g' -e s:172.16.3.16:$cible:g echo '*2 pour les versos, l utilisateur attendra 5 secondes de calme' echo 'ÿ puis recharchera le tas retourne en bloc' echo '*22 mettre les fichiers sur une clef usb branchée à l imac en G207 (à n' echo 'ÿ enlever qu après la réception du message de scannage par mail)' echo '*23 mettre les fichiers sur une clef usb _et_ les envoyer par mail.' echo '*375 resolution 75 dpi' echo '*3100 resolution 100 dpi' echo '*3150 resolution 150 dpi' echo '*3200 resolution 200 dpi' echo '*3300 resolution 300 dpi (implicite)' echo '*3600 resolution 600 dpi' echo '*4 images couleur' echo '*5 pas de compression (scan très long)' echo '*500 pas de compression (scan très long)' echo '*501 tres peu de compression (scan long)' echo '*599 beaucoup de compression (501 à 599 possible, par défaut 540)' echo '*6 il y a plusieurs tas de feuilles (propres et non perforées) à' echo 'ÿ scanner, taper # Annul après le dernier tas. Si le scanner attend' echo 'ÿ 30 secondes, il a détecté un bourrage, remettez le dernier tas en' echo 'ÿ commençant par le recto.' echo '*61 il y a une seule feuille a scanner, sur la vitre cale pres de vous a' echo 'ÿ droite, ou alors un tas de feuille dans le chargeur. (implicite)' echo '*623 il y a 23 feuilles à poser sur la vitre, ou 23 tas a scanner (61 à' echo 'ÿ 6999 possible)' echo '*7623 profondeur du document = 23 milimètres (761 à 76229 possible)' echo '*7723 longueur du document = 23 milimètres (771 à 77381 possible)' echo '*7823 marge vers vous sur vitre = 23 milimètres (781 à 78229 possible)' echo '*7923 marge à gauche sur vitre = 23 milimètres (791 à 79310 possible)' } | tr '\012a' 'a\012' | sed 's:aÿ:ÿ :g' | tr '\012a' 'a\012' | sort | tr 'ÿ' '\012' echo echo 'Il me reste du travail, notamment pour comprendre pourquoi *8 ne marche pas.' echo echo 'Bon scan !' echo ' '$AUTHOR echo echo echo ' ******************************************************************' echo ' *************************** PROBLEMES ****************************' echo ' ******************************************************************' echo echo '(A) Si le scanner biipe et affiche "mémoire faible. Appuyez [entree]" :' echo '(A.g) Taper [Entree] comme suggéré dans le message affiché.' echo '(A.h) le scanner affiche "numerisation annulee", mais va pourtant scanner.' echo echo '(B) Si le scanner ne fait rien du tout et affiche furtivement "ADF" :' echo '(B.g) Vérifiez que le couvercle du chargeur de document est bien fermé.' echo echo '(C) Si le scanner ne fait rien du tout (bruit, mouvements) :' echo '(C.g) Allez voir le bouton on/off de façade du mac du bureau G207.' echo '(C.h) Si ce bouton est allumé, appuyer longtemps sur le bouton on/off de façade du mac pour l éteindre.' echo '(C.i) Appuyer sur le bouton on/off de façade du mac pour le rallumer.' echo '(C.j) Attendre quelques minutes.' echo '(C.k) Reprendre à partir de (a) toute la programmation du scanner.' echo echo '(D) Si le scanner a scanné vos feuilles mais que vous ne recevez rien :' echo '(D.f) Allez voir '$AUTHOR', avec votre adresse e-mail, une clef usb.' # scp /tmp/b $NOROOT@thebes:scans/modemploi.txt last=`ls -d *e | sed 's:e$::' | sort -n | tail -n 1` n=`expr $last + 1`e rm -rf $n while true do sleep 1 # pour l'affichage bref d'un message sur l'écran ... marche pas toujours. #blocs ps `cat /var/run/hpssd.pid` || { echo manque /var/run/hpssd.pid ; exit 0 ; } /usr/share/hplip/hp-info.patched > /home/$NOROOT/scans/scan.automatique.log.clavier 2> /dev/null # script -f -c /usr/share/hplip/hp-info.patched /home/$NOROOT/scans/scan.automatique.log.clavier > /dev/null 2> /dev/null /usr/share/hplip/info.py 2>&1 | { grep 'error: No devices found.' && { echo info.py deconne ; exit 42 ; } ; } grep '#' /home/$NOROOT/scans/scan.automatique.log.clavier || { echo connection avec ecran du scanner interrompue ; exit 42 ; } hp-info | grep 'panel-line2.*' || exit 1 demande=`cat /home/$NOROOT/scans/scan.automatique.log.clavier | grep 'Document charg\|Charger document' | tee -a /home/$NOROOT/scans/scan.automatique.log.clavier.grep | grep -v '/' | sed 's:^.*[a-zA-Z]::' | sed 's: *::' | tr '\015\012*#' Unab | sed s:U::g | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:\([ab0-9][ab0-9][ab0-9][ab0-9][ab0-9]\)n[ab0-9]*\1:\1:g' | sed 's:.*n\(.\):\1:' | sed 's:n$::'` echo $demande sleep 3 resolution=300 echo "$demande" | grep 'a3[0-9][0-9]*[ab]' && { resolution=${demande##*a3} ; resolution=${resolution%%[ab]*} ; } couleur=Gray echo "$demande" | grep 'a4[ab]' && couleur=Color onusb=no echo "$demande" | grep 'a2[23][ab]' && onusb=yes compression=40 echo "$demande" | grep 'a5[ab]' && { compression=0 ; } echo "$demande" | grep 'a5[0-9][0-9]*[ab]' && { compression=${demande##*a5} ; compression=${compression%%[ab]*} ; } compression=`expr 100 - $compression` echo Compression : $compression case "a$compression" in a100) compression="" ;; a*) compression="--compression=jpeg --jpeg-quality=$compression" ;; esac # count='--batch-scan=yes' count='--batch-scan=yes' echo "$demande" | grep 'a6[1-9][0-9]*[ab]' && { count=${demande#*a6} ; count='--batch-count='${count%%[ab]*} ; } onepage='--batch-count=1' taille='--length-measurement=Unknown' echo "$demande" | grep 'a79[0-9]*[ab]' && { tmp=${demande##*a79} ; taille='-t '${tmp%%[ab]*}mm ; echo "$demande" | grep 'a77[0-9]*[ab]' || { taille="$taille "'-y '`expr 381 - ${tmp%%[ab]*}`mm ; } ; } echo "$demande" | grep 'a77[0-9]*[ab]' && { echo "$demande" | grep 'a79[0-9]*[ab]' || taille='' ; tmp=${demande##*a77} ; taille="$taille "'-y '${tmp%%[ab]*}mm ; } echo "$demande" | grep 'a76[0-9]*[ab]' && { tmp=${demande##*a76} ; taille="$taille "'-x '${tmp%%[ab]*}mm ; } echo "$demande" | grep 'a78[0-9]*[ab]' && { tmp=${demande##*a78} ; taille="$taille "'-l '${tmp%%[ab]*}mm ; echo "$demande" | grep 'a76[0-9]*[ab]' || { taille="$taille "'-x '`expr 229 - ${tmp%%[ab]*}`mm ; } ; } mkdir $n cd $n # quand scaniamge bloque avec "Scanned page [0-9]*. (scanner status = 3),", il faut lui envoyer un kill puis un kill -9 case "a$demande" in a*a6[ab]*) case "a$demande" in a*a2[ab]*) echo recto-verso en plusieurs paquets, attention ca ne doit pas bourrer while hp-info | grep 'panel-line2.*/.*$' do mkdir tasencourt res=9 while test $res = 9 do sleep 2 last=`ls ${n}*.pnm | sed 's:^'"${n}"'::' | { echo 0.pnm ; sort -n ; } | tail -n 1 | sed 's:.pnm$::'` cd tasencourt scanimage --resolution=$resolution $compression --mode $couleur --batch-start=`expr $last + 1` --batch-increment=2 --batch-scan=yes $taille --batch="${n}%d.pnm" res=$? test $res = 134 && res=9 echo recto $res $last cd .. done resrecto=$res; lastrecto=$last; res=9 while test $res = 9 do sleep 2 cd tasencourt last=`ls ${n}*.pnm | sed 's:^'"${n}"'::' | { echo 0.pnm ; sort -n ; } | tail -n 1 | sed 's:.pnm$::'` scanimage --resolution=$resolution $compression --mode $couleur --batch-start=`expr $last + 1` --batch-increment=-2 --batch-scan=yes $taille --batch="${n}%d.pnm" res=$? test $res = 134 && res=9 echo verso $res $last cd .. done test $res '=' 7 -a $resrecto '=' 7 -a '(' -e tasencourt/${n}`expr $lastrecto + 2`.pnm ')' -a '!' '(' -e tasencourt/${n}$lastrecto.pnm ')' && mv tasencourt/* . || sleep 300 ; sleep 5 rm -rf tasencourt done echo $? ;; *) echo recto en plusieurs paquets res=9 #scanimage: sane_start: Operation was cancelled (scanner status = 2) (anull entree) # les autres sont : Document feeder jammed 6, ok 5, Error during device I/O 9, Document feeder out of documents 7. while /usr/share/hplip/info | grep 'panel-line2.*/.*$' do # # pas besoin car un tas raté c'est un tas absent. # while test $res = 9 # do sleep 2 last=`ls ${n}*.pnm | sed 's:^'"${n}"'::' | { echo 0.pnm ; sort -n ; } | tail -n 1 | sed 's:.pnm$::'` echo $last scanimage --resolution=$resolution $compression --mode $couleur --batch-scan=yes --batch-start=`expr $last + 1` --batch-increment=1 $taille --batch="${n}%d.pnm" res=$? test $res = 134 && res=9 echo recto $res # done done echo $? ;; esac ;; *) case "a$demande" in a*a2[ab]*) echo recto-verso res=9 while test $res = 9 do sleep 2 scanimage --resolution=$resolution $compression --mode $couleur --batch-start=1 --batch-increment=2 $count $taille --batch="${n}%d.pnm" res=$? test $res = 134 && res=9 echo recto $res done res=9 last=`ls ${n}*.pnm | sed 's:^'"${n}"'::' | { echo 0.pnm ; sort -n ; } | tail -n 1 | sed 's:.pnm$::'` case "a$last" in a1) useadf="0" ;; *) useadf="1" # useadf="--source ADF" ;; esac while test $res = 9 do sleep 2 scanimage --resolution=$resolution $compression --mode $couleur --batch-start=`expr $last + 1` --batch-increment=-2 $count $taille --batch="${n}%d.pnm" res=$? test -e "${n}`expr $last + 1`.pnm" || res=9 test $res = 134 && res=9 echo verso $res done echo $? ;; *) echo recto res=9 while test $res = 9 do sleep 2 #for i in scanimage --resolution=$resolution $compression --mode $couleur --batch-start=1 --batch-increment=1 $count $taille --batch="${n}%d.pnm" #do echo $i >> /home/$NOROOT/scans/args.de.scanimage ; done last=`ls ${n}*.pnm | sed 's:^'"${n}"'::' | { echo 0.pnm ; sort -n ; } | tail -n 1 | sed 's:.pnm$::'` # last pour prendre en charge un bourrage autrement qu'en recommancant a 0. Maintenant, si le scanner voit un nouveau tas, il va rescanner ; si le tas disparait avait qu'il commence a rebouger, il scanne la vitre. scanimage --resolution=$resolution $compression --mode $couleur --batch-start=`expr $last + 1` --batch-increment=1 $count $taille --batch="${n}%d.pnm" res=$? test $res = 7 && { test -s ${n}1.pnm || scanimage --resolution=$resolution $compression --mode $couleur --batch-start=1 --batch-increment=2 $onepage $taille --batch="${n}%d.pnm" ; res=$? ; } test $res = 134 && res=9 echo $res done echo $? ;; esac ;; esac cd .. test $res = 1 && { echo scanimage a rate res egal 1 ; exit 24 ; } case "a$onusb" in ano) { tar cf - $n | ssh $NOROOT@$cible /usr/local/bin/.post.scan ${n} $demande $resolution case "$demande" in *a26[ab]*) ;; *a260[ab]*) cd $n for i in * do cat $i | tr '\000-\377' 'e' > b dd if=b of=$i rm $i done rm b cd .. ;; *) cd $n ssh $NOROOT@$cible echo toto | grep toto && for i in * ; do rm $i ; done cd .. ;; esac } & ;; ayes) clefusb=/mnt/sda1 ; mount /mnt/sda1 || { clefusb=/mnt/sda1.auto ; mount /mnt/sda1.auto || { clefusb=/mnt/sda ; mount /mnt/sda ; } ; } mkdir -p $clefusb/scans/$n { tar cf - $n | { ssh $NOROOT@$cible bin/.post.scan ${n} $demande $resolution || cat ; } | sed '1,/ATTENTIONSUITUNFICHIERTAR456789024354657897865746/d' | tar -C $clefusb/scans/$n -xvvf - ; umount $clefusb ; } || { tar cf - $n | tar -C $clefusb/scans/$n -xvvf - ; umount $clefusb ; } case "$demande" in *a26[ab]*) ;; *a260[ab]*) cd $n for i in * do cat $i | tr '\000-\377' 'e' > b dd if=b of=$i rm $i done rm b cd .. ;; *) cd $n ssh $NOROOT@$cible echo toto | grep toto && for i in * ; do rm $i ; done cd .. ;; esac ;; esac n=`expr ${n%e} + 1`e #exit 1 done