bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strange problem with pipes


From: hubert depesz lubaczewski
Subject: Strange problem with pipes
Date: Wed, 14 Mar 2012 20:58:39 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,
1. bash version: GNU bash, version 4.2.10(1)-release (x86_64-pc-linux-gnu) 

2. test script:
[bash] #!/bin/bash
[bash] remote_ssh_account="depesz@localhost"
[bash] directory_to_tar=pgdata
[bash] exec nice tar cf - "$directory_to_tar" | \
[bash]     tee >(
[bash]         md5sum - | \
[bash]         ssh "$remote_ssh_account" 'cat - > /tmp/h3po4-MD5-2012-03-13.tar'
[bash]     ) | \
[bash]     ssh "$remote_ssh_account" 'cat - > /tmp/h3po4-data-2012-03-13.tar'

exec+nice are irrelevant - without them happens the same thing.

to test it you need directory (pgdba in this case) with non-trivial size
(i test on 1.5GB), and remote (over ssh) account with passwordless
authentication (depesz@localhost in here).

When I run it, I get
tee: standard output: Resource temporarily unavailable

i.e. the "data" ssh seems to fail.

But I did strace, and it looks that this ssh is not getting any data
from anywhere, despite the fact that tee *does* write the data to 1st
fd.

talked about the problem on #bash, and they suggested to change it to:
[bash] #!/bin/bash
[bash] remote_ssh_account="depesz@localhost"
[bash] directory_to_tar=pgdata
[bash] nice tar cf - "$directory_to_tar" | \
[bash]     tee >(
[bash]         md5sum | \
[bash]         ssh "$remote_ssh_account" 'cat > /tmp/h3po4-MD5-2012-03-13.sum'
[bash]     ) > >(
[bash]         ssh "$remote_ssh_account" 'cat > /tmp/h3po4-data-2012-03-13.tar'
[bash]     )

which works.

I also tested version:
[bash] #!/bin/bash
[bash] remote_ssh_account="depesz@localhost"
[bash] directory_to_tar=pgdata
[bash] nice tar c "$directory_to_tar" | \
[bash]     tee >(
[bash]         md5sum - | \
[bash]         ssh "$remote_ssh_account" 'cat - > /tmp/h3po4-MD5-2012-03-13.tar'
[bash]     ) >(
[bash]     ssh "$remote_ssh_account" 'cat - > /tmp/h3po4-data-2012-03-13.tar'
[bash]     ) > /dev/null

It looks that the final pipe breaks. Any idea on what could be wrong?

Best regards,

depesz

-- 
The best thing about modern society is how easy it is to avoid contact with it.
                                                             http://depesz.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]