How to run feeding each other processes simultaneously?


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 2 Weeks Ago
How to run feeding each other processes simultaneously?

Hello,
I need to run multiple shell processes simultaneously and output of the first process shall be the input of the second process but first process is never ending so both should be running in parallel. I do not wish to wait the end of the first process. I am under ubuntu 16.04.

First_process.sh: It is the same with wget, downloads 2389.ts file and put it into directory.
Code:
ffmpeg -y -re -i http://xx.yy.zz/2389.ts ...some_codes_here.... -f mpegts 2389.ts

Second_process.sh:
Code:
tsplay 2389.ts -loop -maxnowait 2 -waitfor 500 -udp 234.5.5.5:5000

Not giving expected method:
Code:
First_process.sh &
Second_process.sh &

This way, I can't get expected output, because first process is never ending. and second process will always be kept waiting by the first one.

After some research, I found below algorithm but could not make it working.

list.txt:
Code:
http://xx.yy.zz/2389.ts

final.sh
Code:
#!/bin/bash
cust_func(){
  ffmpeg -y -re -i "$1" .some_codes_here.. -f mpegts 2389.ts
}
while IFS= read -r url
do
        cust_func "$url" &
tsplay 2389.ts -loop -maxnowait 2 -waitfor 500 -udp 234.5.5.5:5000
done < list.txt
wait
echo "Finished."

But not working... Would Xarg command be a solution ?

Thank you
Boris


Edit:
Sorted by this way:
Code:
ffmpeg -y -re -i http://xx.yy.zz/2389.ts .some_codes_here.. -f mpegts 2389.ts > output.log 2>&1 < /dev/null &
tsplay 2389.ts -loop -maxnowait 2 -waitfor 500 -udp 234.5.5.5:5000


Thanks
Boris

Last edited by baris35; 2 Weeks Ago at 08:34 PM.. Reason: sorted
# 2  
Old 2 Weeks Ago
I'd think this is what pipelines (command1 | command2) are for.
# 3  
Old 2 Weeks Ago
Hello Rudic,
I agree with you but unfortunately not working like this way:
Code:
command 1 | command2

Somehow, command2 is waiting for the first command to be finished.
Redirection to /dev/null method is okay.

Kind regards
Boris
# 4  
Old 2 Weeks Ago
Probably because your commands aren't written to work that way.

wget must write to a pipe, not a file, second command must read from pipe, not file, etc, etc, etc.

For wget, that means -O - to make it write to standard output. not sure what that means for ffmpeg, etc. If - doesn't work as an input/output filenames, /dev/stdin and /dev/stdout might.

Last edited by Corona688; 2 Weeks Ago at 11:29 AM..
This User Gave Thanks to Corona688 For This Post:
baris35 (2 Weeks Ago)
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Run 2 shell scripts simultaneously from one script Ganesh Mankar Shell Programming and Scripting 11 02-21-2015 07:16 AM
Maximum no of processes that can run jansat UNIX for Dummies Questions & Answers 4 02-16-2012 06:01 PM
Slow run processes after abnormal reboot buyantugs Solaris 0 06-06-2011 04:01 AM
how to run more than two processes parallely venugopalsmartb UNIX and Linux Applications 2 04-10-2011 06:37 AM
kill my processes which are run by hacker thsecmaniac Shell Programming and Scripting 1 07-13-2010 01:04 AM
Run two CGIs simultaneously and Ajax to read updated value from CGI1 xs2punit Programming 8 06-11-2010 12:06 PM
[Help] script how to run 2 commands simultaneously funnyguy123 Shell Programming and Scripting 2 12-19-2009 02:39 AM
Run a command in bg simultaneously with King Nothing Shell Programming and Scripting 0 06-04-2009 10:57 AM
run serveral loops simultaneously? fedora Shell Programming and Scripting 2 01-22-2009 12:08 PM
Multiple processes writing on the same file simultaneously Sayantan Shell Programming and Scripting 1 01-23-2008 02:28 AM
script to run different shells which run different processes mochi UNIX for Advanced & Expert Users 2 06-15-2006 12:25 PM
Run 4-processes concurrently ugp Programming 9 03-03-2006 05:08 AM
Run away processes lowtaiwah UNIX for Advanced & Expert Users 2 02-16-2006 01:45 AM
preventing others to run processes on my machine besharam UNIX for Advanced & Expert Users 3 10-17-2005 02:32 PM
How to run processes in parallel? sbasak Shell Programming and Scripting 3 11-03-2004 12:12 PM