How to run feeding each other processes simultaneously?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run feeding each other processes simultaneously?
# 1  
Old 03-07-2019
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; 03-07-2019 at 09:34 PM.. Reason: sorted
# 2  
Old 03-08-2019
I'd think this is what pipelines (command1 | command2) are for.
# 3  
Old 03-08-2019
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 03-08-2019
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; 03-08-2019 at 12:29 PM..
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run 2 shell scripts simultaneously from one script

i Run 2 scripts on all of around 50 nodes every day. 1.Mod_1.sh 2.Mod_2.sh eg.. i run file with specific node no like Mod_1.sh NODE_(node number) Mod_2.sh NODE_(node number) I want to run both file by using single script with unique node number. Eg.. Mod_new.sh NODE_(node... (11 Replies)
Discussion started by: Ganesh Mankar
11 Replies

2. Programming

Run two CGIs simultaneously and Ajax to read updated value from CGI1

Flow of program: C based CGI is used CGI1: -Gets called when user hits upload button(submit) ie form action = CGI1 -Does the file upload (copy to a directory etc) JS, Ajax fucntion: -A JS function is called when user hits upload button -The JS function opens an Ajax request for CGI2... (8 Replies)
Discussion started by: xs2punit
8 Replies

3. Shell Programming and Scripting

[Help] script how to run 2 commands simultaneously

#!/bin/sh firefox index.html firefox secondpage.html hey guys, im not able to open up two pages at the same time... it always open up index.html first, and only after i close it, then the 2nd page pops up... is there any way i can run both commands at the same time? i appreciate any... (2 Replies)
Discussion started by: funnyguy123
2 Replies

4. Shell Programming and Scripting

Run a command in bg simultaneously with

Hi, I want to run the command below in the background: tail -f file.txt | grep "pattern" The file file.txt will start getting its contents written after this command has started getting run. So the flow will be like this tail -f file.txt | grep "pattern" #The line below will write data... (0 Replies)
Discussion started by: King Nothing
0 Replies

5. Shell Programming and Scripting

run serveral loops simultaneously?

Hello everyone, say I have the following script, which contains serveral loops, if I run the script, it executes the loop one by one (after the a loop, it goes to b loop, then c, then d) I figured I should be able to run all the loops at same time, but I don't know how, can anyone help a little... (2 Replies)
Discussion started by: fedora
2 Replies

6. Shell Programming and Scripting

Multiple processes writing on the same file simultaneously

Hi All, I have encountered a problem,please help me. I have a script in which multiple processes are writing on to the same file . How should I stop this , I mean lock mechanism can be implemented or we can write the at different files and then concatenate the files. What would be a better... (1 Reply)
Discussion started by: Sayantan
1 Replies

7. UNIX for Advanced & Expert Users

script to run different shells which run different processes

Hi, Would like to ask the experts if anyone knows how to run a script like this: dtterm -title shell1 run process1 on shell1 dtterm -title shell2 run process2 on shell2 cheers! p/s: sorry if i used the wrong forum, quite concussed after watching world cup for several nights; but I... (2 Replies)
Discussion started by: mochi
2 Replies

8. Programming

Run 4-processes concurrently

How can i run a back ground process.... I.e for example by using fork() i need to run seperate 4 background processes.. How can send a process to background ??? (9 Replies)
Discussion started by: ugp
9 Replies

9. UNIX for Advanced & Expert Users

Run away processes

Hi, My server runnning on SUN Solaris rel.5.5.1. I have been facing this issues for years. I have some Xbase databases running on the server. User is using emulation software to telnet to server for accessing application. If user logout application abnormally - by closing windows session, then... (2 Replies)
Discussion started by: lowtaiwah
2 Replies

10. Shell Programming and Scripting

How to run processes in parallel?

In a korn shell script, how can I run several processes in parallel at the same time? For example, I have 3 processes say p1, p2, p3 if I call them as p1.ksh p2.ksh p3.ksh they will run after one process finishes. But I want to run them in parallel and want to display "Process p1... (3 Replies)
Discussion started by: sbasak
3 Replies
Login or Register to Ask a Question