parallel
[Top][All Lists]
Advanced

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

--cat and --fifo


From: Ole Tange
Subject: --cat and --fifo
Date: Sun, 23 Mar 2014 01:41:33 +0100

Sometimes I meet commands that cannot read from stdin, but only from a
file or a fifo. You may be lucky that you can do:

    parallel --pipe 'command <(cat)'

But you may have to wrap that kind of commands  to make them work with
'parallel --pipe':

    parallel --pipe 'cat > {#}; command {#}; _EXIT=$?; rm {#}; exit $_EXIT'
    parallel --pipe 'mkfifo {#}; (command {#}) & _PID=$!; cat > {#};
wait $_PID;  _EXIT=$?; rm {#}; exit $_EXIT'

Not really elegant and if the file {#} already exists, it will be over
written. So I have implemented --cat and --fifo:

    parallel --pipe --cat 'command {}'
    parallel --pipe --fifo 'command {}'

The do the same as above except the filename is a tmpfile, so the
chance for overwriting 0 if run locally, and close to 0 if run
remotely.

--cat and --fifo do not make sense without --pipe, and I am thinking
that I could probably autodetect if the command contains {} then it
means '--pipe --cat'. But that might be surprising to the user, that
including {} in the command will run slower (as the cat will first
save stdin to a tmpfile).

--cat and --fifo could also just imply --pipe.

What do you think? How would you like them to work? Do you have more
describing names?

Test --cat and --fifo by:

    git clone git://git.savannah.gnu.org/parallel.git


/Ole



reply via email to

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