[TriLUG] How to debug piping issues

Brian Henning via TriLUG trilug at trilug.org
Wed Mar 30 10:37:21 EDT 2016


The command would be this:

$ zbarcam --raw | xargs xdotool type

...and wouldn't work for the same reason: no EOF.  No EOF comes as long as the pipe is open, and xargs (and xdotool) don't act until they see the EOF.

I wrote a perl script to demonstrate.  echoer.pl simply reads stdin and prints it to stdout, line by line.  Observe:

(--max-args tells xargs how many arguments to pass to each invocation of its command; without it, it will read a system-defined number of arguments from stdin separated by any sort of whitespace)

brian at blueman:~/oldbruce$ ./echoer.pl | xargs --max-args=1 xdotool type --clearmodifiers
This
is
highly
irregular
Thisishighlyirregularbrian at blueman:~/oldbruce$ Thisishighlyirregular

I pressed Ctrl-D (EOF) after typing "irregular"; this placed an EOF on stdin, which caused echoer.pl to exit, which placed an EOF on the pipe.  Only then did xargs spring into action, executing xdotool with the characters I'd entered.

In fact it proves my hunch about xdotool waiting for EOF itself:

brian at blueman:~/oldbruce$ ./echoer.pl | xdotool type --clearmodifiers --file -
This is
also
highly 
irregular
This isalsohighlyirregularbrian at blueman:~/oldbruce$ This isalsohighlyirregular

Well, this thread had the intended result: it helped me figure out how to debug a pipe that wasn't working how I expected.  Thanks!

-B



-----Original Message-----
From: TriLUG [mailto:trilug-bounces at trilug.org] On Behalf Of Chris Baldwin via TriLUG
Sent: Tuesday, March 29, 2016 11:40 PM
To: trilug at trilug.org
Subject: Re: [TriLUG] How to debug piping issues

Silly question - what does xdotool expect?

Is it this xdotool: 
http://manpages.ubuntu.com/manpages/lucid/man1/xdotool.1.html ?

Have you tried xargs, i.e. "zbarcam --raw | xargs xdotool type --file -" ?

-Chris

On 3/28/16 8:35 PM, Reid Thompson via TriLUG wrote:
> Just wondering, did you try that command without the --file? My man 
> page example for stdin doesn't have it.
>
> On Sun, Mar 27, 2016, 23:24 Brian via TriLUG <trilug at trilug.org> wrote:
>
>> On 03/27/2016 12:13 AM, Steven Tardy wrote:
>>>> On Mar 26, 2016, at 11:33 PM, Brian via TriLUG <trilug at trilug.org>
>> wrote:
>>>> $ zbarcam --raw | xdotool type --file -
>>> Typical buffering, probably have to send 4kB before the second 
>>> program
>> sees anything. Google suggests "unbuffer" may prevent the pipe from 
>> buffering.
>> $ unbuffer zbarcam --raw | xdotool type --file -
>>
>> No difference :-(
>>
>> Plus it seems as though if 4k buffering were the issue, my perl 
>> script (run this way: zbarcam --raw | barwedge.pl ) would have the 
>> same problem, and it doesn't.
>>
>> Maybe there's something about how xdotool type --file - expects the 
>> stdin file handle to behave (perhaps it doesn't type anything until 
>> it sees an EOF or something).
>>
>> Anyway, thanks!
>> -B
>>
>>
>> --
>> This message was sent to: jreidthompson at gmail.com 
>> <jreidthompson at gmail.com To unsubscribe, send a blank message to 
>> trilug-leave at trilug.org from that address.
>> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
>> Unsubscribe or edit options on the web  :
>> http://www.trilug.org/mailman/options/trilug/jreidthompson%40gmail.co
>> m Welcome to TriLUG: http://trilug.org/welcome

--
This message was sent to: Brian <bhenning at pineinst.com> To unsubscribe, send a blank message to trilug-leave at trilug.org from that address.
TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
Unsubscribe or edit options on the web	: http://www.trilug.org/mailman/options/trilug/bhenning%40pineinst.com
Welcome to TriLUG: http://trilug.org/welcome


More information about the TriLUG mailing list