views:

323

answers:

1

Hello,

I am using zbarcam to read barcode from a webcam in my webapps. But, since zbarcam display a \n at the end, my form is submit.

Here is what I use :

read_one.py

#!/usr/bin/python
from sys import argv
import zbar
import webbrowser

# create a Processor
proc = zbar.Processor()

# configure the Processor
proc.parse_config('enable')

# initialize the Processor
device = '/dev/video0'
if len(argv) > 1:
    device = argv[1]
proc.init(device)

# enable the preview window
proc.visible = True

# read at least one barcode (or until window closed)
proc.process_one()

# hide the preview window
proc.visible = False

# extract results
for symbol in proc.results:
    # do something useful with results
    print symbol.data

keyboard.sh

python read_one.py | xvkbd -file -

How can I either remove the '\n' before sending the barcode to xvkbd or disable the enter key in xvkbd ?

+1  A: 

Try this:

printf "$(python read_one.py)" | xvkbd -file -
Dennis Williamson
Perfect, thank you.
Natim