1

I have a situation that I need to run different executables from different linux directories. The executables communicate through IP/TCP and the master-worker concept. Here I have a master directory which contains the master executable and different worker directories which contain the worker executables. Here is an example of what I'm trying to do:

A- I have a master directory : /home/usr/scratch/master
B- I create an exact copy of master copy called it wrk1 
    :/home/usr/scratch/wrk1
C- cd to master directory and run the exe command: 
   ./exe arg1 /h :4004
where 4004 is a port number and arg1 and /h are just some arguments of exe
D- cd to wrk directory and run the following commands: 
   ./exe_wrk arg1 /h host:4004

Where host is the hostname of master directory

I wrote a simple sh script :

1- cd /home/usr/scratch/master
2- ./exe /h :4004
3- cd /home/usr/scratch/wrk1
4- ./exe /h host:4004

The problem is the program when I run the master exe, it pauses and waits for other worker exe to run. In another word, my script pauses at step 2 so it never get to step 3 and four to run the workers. I can do it manually by opening another terminal and run workers but is there any way that I can run it automatically?

Ress
  • 667
  • 1
  • 7
  • 24
  • 1
    Possible duplicate of [Asynchronous shell commands](https://stackoverflow.com/questions/2368137/asynchronous-shell-commands) – Jonny Henly Nov 16 '18 at 17:54
  • I tried the "myscript &" suggested there, but it still doing the same thing. It pauses at step two and never cd to wrk directory. – Ress Nov 16 '18 at 18:01
  • 1
    The accepted answer states *"Note that this is different from putting the `&` inside your script, which probably won't do what you want."* Did you look at the other answers with more options, or research using `&` in a script? – Jonny Henly Nov 16 '18 at 18:04
  • I think you want `.exe .... &` for each mention of `.exe` **inside your script**. Good luck. – shellter Nov 16 '18 at 18:41

0 Answers0