gcat.sh
#!/bin/sh
function is_number(){
[[ `expr "$1" + 0 2>&1 | grep non | wc -l` -eq 0 ]]
}
echo
echo GED\'s scan capture \(c\) 2004
echo ironstorm@users.sf.net
echo
echo TODO handle books
echo
while true;
do
echo
echo Ready\! Scan your product
echo \(hit Ctrl-C to quit\)
echo
upc=
desc=
size=
manufacturer=
ptype=
read upc
is_number "$upc"
if [ "$?" = "0" ]; then
echo
if [ "`cat scan-data.txt | grep "$upc" | wc -l`" = "0" ]; then
echo UPC \= $upc
read -p "Enter manufacturer: " manufacturer
while is_number "$manufacturer";
do
echo Stop scanning\!
read -p "Enter manufacturer: " manufacturer
done
read -p "Enter product description: " desc
read -p "Enter size/qty/weight/type: " ptype
echo \ >> scan-data.txt
echo \$upc\<\/upc\> >> scan-data.txt
echo \$manufacturer\<\/manufacturer\> >> scan-data.txt
echo \$desc\<\/description\> >> scan-data.txt
echo \$ptype\<\/type\> >> scan-data.txt
echo \<\/product\> >> scan-data.txt
else
echo Duplicate UPC \( $upc \)!
echo
fi
else
echo
echo Invalid UPC $upc
echo Re-scan
fi
done