help-bash
[Top][All Lists]
Advanced

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

Re: How to force delay in command execution in unamed pipe?


From: Andreas Kusalananda Kähäri
Subject: Re: How to force delay in command execution in unamed pipe?
Date: Sun, 3 Apr 2022 08:54:49 +0200

On Sun, Apr 03, 2022 at 12:11:37AM -0500, Peng Yu wrote:
> Hi
> 
> cmd <(cmd1) <(cmd2)
> 
> For a command like the above, I will need to let cmd2 run after cmd1
> finishes. Of course, one could use temp files like the following. But
> is there a way to follow such a constraint with unnamed pipes?
> 
> cmd1 > file1
> cmd2 > file2
> cmd file1 file2
> 
> Another way to avoid using unnamed pipes is to use a pipeline with
> redirection like this. Is there a way to force cmd2 to run only after
> cmd1 finishes in this pattern?
> 
> cmd1 | {
> cmd2 | {
> cmd "$fd1" "$fd2"
> } {fd2}<&0
> } {fd1}<&0
> 
> -- 
> Regards,
> Peng

Please say more about what "cmd1", "cmd2", and "cmd" do, and especially
in what order "cmd" is consuming data from the files mentioned on its
command line. If "cmd1" needs to deposit its complete output somewhere
before "cmd2" is allowed to run, then 

* "cmd1" is only allowed to write a small enough amount of data as to
not fill the pipe buffer, or

* "cmd1" needs to write to a file, or

* "cmd" needs to consume the output from "cmd1" before reading the data
from "cmd2" (this would incidentally also mean "cmd2" would block until
"cmd1" finishes, which in a sense solves your issue, depending on the
amount of data "cmd2" produces and whether you're piping or redirecting
the outputs, and whether you mean "start" when you say "run" or not.)


-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.



reply via email to

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