[TriLUG] How to debug piping issues
Brian via TriLUG
trilug at trilug.org
Sat Mar 26 23:33:41 EDT 2016
Hi there!
I thought I'd be clever and use zbarcam (a webcam barcode reader) and
xdotool (a keyboard/mouse event generator) to create a
keyboard-wedge-style barcode reader. Here's the command I use:
$ zbarcam --raw | xdotool type --file -
The --raw option tells zbarcam to write out only the data in the barcode
it read, plus a newline.
The type command to xdotool means generate some typing events
The --file - option to that command means read standard input for what
to type
Only thing is, it doesn't work. xdotool doesn't type anything. But I
can do this:
$ zbarcam --raw | tee afile
[scan a code][press ^C]
$ cat afile | xdotool type --file -
... and it works, typing out the barcode I scanned.
So.. Why does a direct pipe not work? Piping out of zbarcam clearly
works (tee writes stuff to the file) and piping in to xdotool clearly
works (xdotool types the stuff cat-piped into it). What could be going
wrong here?
I got around the problem by writing a perl script that reads from stdin
and system()s a call to xdotool, but I'd still love to understand what's
going on with the simple pipe...
Thanks,
-B
More information about the TriLUG
mailing list