#! /bin/bash # # Johannes Meixner , 2004, 2005, 2006 #set -x export PATH="/sbin:/usr/sbin:/usr/bin:/bin" export LC_ALL="POSIX" export LANG="POSIX" umask 022 MY_NAME=${0##*/} # Input: # Create temporary files: TMP_DATA=$(mktemp -u /tmp/$MY_NAME.XXXXXX) # Extract USB entries from the models.dat file: test -n "$1" && RULES_FILE="$1" || RULES_FILE="models.dat" ls $RULES_FILE &>/dev/null || { echo "$MY_NAME error: Required models.dat file '$RULES_FILE' not found." 1>&2 ; exit 3 ; } tr '[:upper:]' '[:lower:]' <$RULES_FILE | egrep '^usb-pid=[0-9a-f][0-9a-f][0-9a-f][0-9a-f]$' | grep -v '0000' | cut -s -d '=' -f 2 | sort -u >$TMP_DATA tr '[:upper:]' '[:lower:]' <$RULES_FILE | egrep '^usb-pid=[0-9a-f][0-9a-f][0-9a-f]$' | grep -v '000' | cut -s -d '=' -f 2 | sort -u | sed -e 's/^/0/' >>$TMP_DATA # Output: # Output header: echo '' echo '' echo ' ' # Output model specific HP USB device entries: exec <$TMP_DATA while read PRODUCT do echo echo ' ' echo ' ' echo -n ' ' echo ' scanner' echo ' ' echo ' ' echo ' ' done # Output footer: echo echo ' ' echo '' # Remove the temporary file rm $TMP_DATA exit 0