run scriptin userspace on barcode being scanned

view full story

http://www.linuxquestions.org – I have a usb barcode scanner that is recognized as HID device and works fine as a keyboard. I have a small program (that i found and don't understand) that decodes the barcode and outputs the numbers (it seems letters are missing). I can run this program before login and thereby have a headless barcode scanner. I want a way to execute a script based on the barcode being scanned. For example I want a barcode with the text "import" and it will run a script called import. I don't want to have to program each script and connect it with a specific key-stroke rather it should use the barco (HowTos)