2

Good day everyone,

I am working on a project that requires me to have 7+ programs (no GUI, runs on shell) open, all interacting with each other. For example, Program 1 asks a question to Program 2, and it uses Program 3 and 4 to solve that etc.

So what I do is, I open many terminals and run each one on a different terminal, then I place them on my screen and go ahead. But this is a troublesome process, as every time I need to recompile I need to run them all one by one again, even worse, if I ever turn my computer off, I need to open many shells, go to the directories, run them all so and so.

What I want is a file that would open the necessary terminal windows for me and go to the correct directory on each, then run the programs. I don't know much about shell-scripts, but I assumed this must have been possible. Can you give me any directions? Note that the programs should not run in background or in different tabs. I need to be constantly observing the displays.

I have read this post about a similar issue but that does not work for me, because I need them on different terminals.

Thank you.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
Levent
  • 25
  • 4
  • 2
    This sounds like a job for [tag:tmux] or [tag:screen] – glenn jackman Jun 01 '21 at 01:41
  • If you really want to use new terminal windows, how do you normally start a terminal on your system? Can you maybe figure out the command it uses? – Some programmer dude Jun 01 '21 at 01:49
  • @Someprogrammerdude Well actually I click on the button that runs a terminal, but I think you are talking about the executable of the terminal, right? If I find it, I can open different terminals by running a command. But then how would I run commands on the _new_ terminals? – Levent Jun 01 '21 at 01:54
  • If you can find the command used to run the terminal program, and can run it from inside a shell, you can then run it using the `--help` option to see what argument it takes. Perhaps one of them is for running a program *or script*? – Some programmer dude Jun 01 '21 at 01:57
  • With all this said, there are possibly better solutions, like the ones mentioned by @glenn. – Some programmer dude Jun 01 '21 at 01:59
  • @glennjackman I have been checking out screen for the last 30 minutes, and it actually looks like a good way to solve it. I will check out tmux now and see how it differs. Thank you for the help. – Levent Jun 01 '21 at 02:28
  • @Someprogrammerdude I see how that could work, and I will look more into this. Screen and tmux seem okay, but I can't use my mouse on screen (don't know about tmax yet) and it would be great to have the option. Thanks for the idea! – Levent Jun 01 '21 at 02:29
  • @Levent: You did not say what terminal you are planning to use. How to start this terminal from the command line and at the same time pass to it a command to run, is however not really a programming question and should better be posted at [su]. – user1934428 Jun 01 '21 at 09:40

1 Answers1

1

We suppose you are using gnome terminale, so the command would be:

gnome-terminal --working-directory "{{APP_FOLDER}}" --command "{{APP_EXCUTABLE}}"

That approach can be traslated to any other terminal emulator.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
  • 1
    You might add that user will need to add `&` to end of each line if he wants to start multiple terminals in parallel. – Mark Setchell Jun 01 '21 at 08:21